1.获取系统当前时间
-(NSString *)getTimeNow
{
NSString* date;
NSDateFormatter * formatter = [[NSDateFormatter alloc ] init];
[formatter setDateFormat:@"YYYY-MM-dd hh:mm:ss:SSS"];
date = [formatter stringFromDate:[NSDate date]];
NSString *timeNow = [[NSString alloc] initWithFormat:@"%@", date];
return timeNow;
}
有时候当我们开发做项目的时候,后台的数据会传过来时间的数据是时间戳的格式,我们应该要将这个时间戳转化为时间格式
+(NSString *)timeHelpWithTime:(NSString *)timeStr //timeStr為时间戳 返回的数据就是正常的时间格式
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"YYYY.MM.dd HH:mm:ss"];
NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[timeStr integerValue]];
return [formatter stringFromDate:confromTimesp];
}
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
3.获取系统唯一标示 uuid
NSString *uuid = [[NSBundle mainBundle] bundleIdentifier];
NSString *os = [[UIDevice currentDevice] systemVersion];