NS-Date/NSDateFormatter
//
// main.m
// NS-Date
//
// Created by qianfeng on 15/6/23.
// Copyright (c) 2015年 qianfeng. All rights reserved.
// #import <Foundation/Foundation.h>
//DSdate
int main(int argc, const char * argv[]) {
@autoreleasepool {
//格林威治时间
//获取当前时间
NSDate *date =[NSDate date];
NSLog(@"%@",date);
//当前时间加上时间间隔后的时间点
NSDate *date1 =[NSDate dateWithTimeIntervalSinceNow:120];
NSLog(@"%@",date1);
NSLog(@"%@",[NSDate distantFuture]); NSLog(@"%f", [date timeIntervalSinceNow]);
//时间戳类
//YY 或 yy 或 YYYY //yyyy 年份
//MM .MMMM,MMM,M,
//dd 表示一个月的第多少天
//DD 表示一年的第多少天
//hh;12进制的时间,HH:24进制时间
//ss:表示秒数 SS表示毫秒 以100为单位
NSDateFormatter *dateFormatter =[[NSDateFormatter alloc] init];
dateFormatter.dateFormat =@"yy/MM/dd hh:mm:ss"; NSString *dateString =[dateFormatter stringFromDate:[NSDate date]];
NSLog(@"%@",dateString);
//把时间字符串转换成时间,按照指定格式.
NSLog(@"%@",[dateFormatter dateFromString:@"2014/09/12 12:11:22"]);
}
return 0;
}
NS-Date/NSDateFormatter的更多相关文章
- Foundation框架下的常用类:NSNumber、NSDate、NSCalendar、NSDateFormatter、NSNull、NSKeyedArchiver
========================== Foundation框架下的常用类 ========================== 一.[NSNumber] [注]像int.float.c ...
- NSDateFormatter
NSDate *now = [NSDate date]; NSDateFormatter *fmt = [[NSDateFormatter alloc] init]; fmt.dateFormat = ...
- SugarSync网盘之NSDateFormatter
NSDateFormatter 在获取sugarsync网盘的accessToken时候,得到了过期时间.但是这里的过期时间采用的是世界标准时间UTC,而该网盘是国外的,所以在国内显示的时间就不对了, ...
- iOS-时间戳(或date)转字符串
1.时间戳转字符串 ///时间戳转化为字符转0000-00-00 00:00 + (NSString *)time_timestampToString:(NSInteger)timestamp{ NS ...
- objc:NSDateFormatter使用备忘
NSDateFormatter类的实例可以将字符串的日期表示转换为NSDate对象或者反向转换. 如果只要显示日期不需要时间,则可以用-setDateStyle方法来设置显示日期的格式,有以下几种: ...
- iOS开发--NSDateFormatter
NSDate对象包含两个部分,日期(Date)和时间(Time).格式化的时间字符串主要也是针对日期和时间的 1.基础用法 NSDate* now = [NSDate date]; NSDateFor ...
- iOS 小知识点(持续更新)
1.如何通过代码设置Button title的字体大小 设置Button.titleLabel.font = [UIFont systemFontOfSize:<#(CGFloat)#> ...
- iOS JsonModel 的使用
本文转自:http://blog.csdn.net/smking/article/details/40432287 下面讲一下JSONModel的使用方法. @inteface MyModel : J ...
- JSONModel解析数据成Model
转自:http://blog.csdn.net/smking/article/details/40432287 JSONModel, Mantle 这两个开源库都是用来进行封装JSON->Mod ...
- iOS JsonModel
iOS JsonModel 的使用 本文转自:http://blog.csdn.net/smking/article/details/40432287 下面讲一下JSONModel的使用方法. @in ...
随机推荐
- SASS优化响应式断点管理
前端开发whqet,csdn,王海庆,whqet,前端开发专家 原文:<Managing Responsive Breakpoints with Sass> 作者:Hugo Giraude ...
- Node.js简单介绍
Node.js是一个能够让javascript执行在server上的平台,既是语言又是平台. Node.js是一个实时web应用程序的平台. Node.js有强大的包管理器npm,故node相关软件安 ...
- GLSL 基础量定义
GLSL语法跟C语言非常相似: 1.数据类型: GLSL包含下面几种简单的数据类型 float bool :false or ture int 向量: vec {2,3,4} 长度为2, ...
- QProcess调用外部程序方式的差异
众所周知QProcess类的作用是启动一个外部的程序并与之交互它有三种方式调用外部程序: 1. execute 2. start 3. startDetached 从调用上看: execute是阻塞调 ...
- [Javascript] Monads
Monads allow you to nest computations. They are a pointed functor that adds mjoin and chain function ...
- iOS开发——UI_swift篇&UITableView实现单元格展开与隐藏
UITableView实现单元格展开与隐藏 关于UITableView的展开的收缩在前面的文章我已经结束,就是使用代理,通知,block传值的时候实现的,当时是使用一个Bool值来实现,最后使用着三 ...
- CODE:BLOCK中的CreateProcess: No such file or directory
现象: WINDOWS安装MINGW4.8.1,环境变量设置后,命令行窗体G++能够执行.但编译文件时提示: CreateProcess: No such file or directory. 安装C ...
- Samba服务器配置参考链接
一步一学Linux与Windows共享文件Samba(很适合初学者,极力推荐): http://os.51cto.com/art/200709/56395.htm 由最简单的一个例子说起,匿名用户可读 ...
- 十六款值得关注的NoSQL与NewSQL数据库--转载
原文地址:http://tech.it168.com/a2014/0929/1670/000001670840_all.shtml [IT168 评论]传统关系型数据库在诞生之时并未考虑到如今如火如荼 ...
- mysql重连,连接丢失:The last packet successfully received from the server--转载
原文地址:http://nkcoder.github.io/blog/20140712/mysql-reconnect-packet-lost/ 1.1 错误信息: Caused by: com.my ...