需要设置Locale
NSDateFormatter *dateFormatter = [[[NSDateFormatter
alloc]
init] autorelease];
[dateFormatter
setDateFormat:@"yyyyMMddHHmmss"];
NSDate *currentDate = [[[NSDate
alloc] init]
autorelease];
[dateFormatter setCalendar:[NSCalendar
autoupdatingCurrentCalendar]];
[dateFormatter setLocale:[[[NSLocale
alloc] initWithLocaleIdentifier:@"en_US"]
autorelease]];
NSString *strDate = [dateFormatter
stringFromDate:currentDate];
http://stackoverflow.com/questions/7072267/why-does-my-nsdateformatter-sometimes-return-an-a-m-or-p-m-with-yyyymmddhhmmss
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-11-08 19:58:56