// 获取当前时间戳
+ (NSString *)getCurrentTime
{
NSDate *senddate = [NSDate date];
// NSLog(@"date1时间戳 = %ld",time(NULL));
NSString *date2 = [NSString stringWithFormat:@"%ld", (long)[senddate timeIntervalSince1970]*1000];
return date2;
}
// 时间戳字符串 转换成 时间
+ (NSString *)getTimeWithIntervalSince:(NSString *)timeinter
{
NSTimeInterval time1=[timeinter doubleValue]/1000;
NSDate * date1=[NSDate dateWithTimeIntervalSince1970:time1];
NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@"YYYY-MM-dd"];
NSString * Timestring= [dateformatter stringFromDate:date1];
return Timestring;
}
网友评论