+(NSInteger)timeSwitchTimestamp:(NSString *)formatTime andFormatter:(NSString *)format{
format = @"yyyy-MM-dd HH:mm:ss";
// formatTime = @"2023-05-04 18:40:22";
NSDateFormatter *dateformatter = [[NSDateFormatter alloc]init];
//设置本地区就可以得到24小时制时间,不论手机是12不时制还是24小时制
NSLocale *zh_CNLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
dateformatter.locale = zh_CNLocale;
[dateformatter setDateFormat: format];
NSDate *date = [dateformatter dateFromString:formatTime];
long timeStamp = [date timeIntervalSince1970];
return timeStamp;
}
网友评论