iOS 时间

时间:2015-07-01 20:12:41   收藏:0   阅读:121

1.获取系统当前时间

NSDate *  senddate=[NSDate date];

NSDateFormatter  *dateformatter=[[NSDateFormatter alloc] init];

[dateformatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];

NSString * str=[dateformatter stringFromDate:senddate];

2.获取当前系统时间的秒数

NSTimeInterval time = [[NSDate date] timeIntervalSince1970];

long long int date = (long long int)time; 

3.以秒数来获取的时间

NSDate * d=[NSDate dateWithTimeIntervalSince1970:date];    

NSDateFormatter * dateformatter=[[NSDateFormatter alloc] init];

[dateformatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

NSString * s=[dateformatter stringFromDate:d];

原文:http://www.cnblogs.com/tongyuling/p/4613760.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!