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];
时间: 2024-10-11 01:04:55