-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
在NSTimer+SSAdd分类中
//时间戳转换成时间(YYYY-MM-dd HH:mm:ss)
+ (NSString *)getTimeWithTimeStamp:(long)timeStamp{
// 格式化时间
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:8];
[formatter setDateStyle:NSDateFormatterMediumStyle];
[formatter setTimeStyle:NSDateFormatterShortStyle];
[formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
// 毫秒值转化为秒 /1000
NSDate* date = [NSDate dateWithTimeIntervalSince1970:timeStamp];
NSString* dateString = [formatter stringFromDate:date];
return dateString;
}
时区的转化好像有点问题,显示的依旧是零时区时间,改成
formatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:8*3600];
就正常显示了
作者有时间看下这里
感谢开源~
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels