iOS NSDateFormatter 适合任何国家的时间格式

+ (NSString*)timeFormatted:(int64)totalSeconds

{

    NSDate *date = [NSDate dateWithTimeIntervalSince1970: totalSeconds/1000];

    return [NSDateFormatter localizedStringFromDate:date dateStyle:kCFDateFormatterNoStyle        timeStyle:NSDateFormatterShortStyle];

}


typedef CF_ENUM(CFIndex, CFDateFormatterStyle) { // date and time format styles

kCFDateFormatterNoStyle = 0,

kCFDateFormatterShortStyle = 1,

kCFDateFormatterMediumStyle = 2,

kCFDateFormatterLongStyle = 3,

kCFDateFormatterFullStyle = 4

};


typedef NS_ENUM(NSUInteger, NSDateFormatterStyle) {    // date and time format styles

    NSDateFormatterNoStyle = kCFDateFormatterNoStyle,

    NSDateFormatterShortStyle = kCFDateFormatterShortStyle,

    NSDateFormatterMediumStyle = kCFDateFormatterMediumStyle,

    NSDateFormatterLongStyle = kCFDateFormatterLongStyle,

    NSDateFormatterFullStyle = kCFDateFormatterFullStyle

};



你可能感兴趣的:(iOS NSDateFormatter 适合任何国家的时间格式)