标签:
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