Jim*_*Jim 3 iphone cocoa-touch objective-c ios
NSLog(@"Time From DB %@", mytime.beginTime);
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
[timeFormatter setDateFormat:@"hh:mm a"];
UILabel *timeLabel = (UILabel *)[cell viewWithTag:1];
timeLabel.text = [timeFormatter stringFromDate:mytime.beginTime];
NSLog(@"Time after formatting %@", timeLabel.text);
[timeFormatter release];
Run Code Online (Sandbox Code Playgroud)
安慰
2011-07-05 11:16:09.331 My project[1907:207] Time From DB 2011-05-10 13:54:09 +0000
2011-07-05 11:16:09.331 My project[1907:207] Time after formatting 04:54 PM
Run Code Online (Sandbox Code Playgroud)
为什么时代不同?如何解决?
它使用用户的时区(默认).如果您想在GMT中使用它,则必须设置日期格式化程序的时区.
[timeFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
Run Code Online (Sandbox Code Playgroud)
BTW时代并没有什么不同.时间是相同的,但在不同的时区表示.
| 归档时间: |
|
| 查看次数: |
150 次 |
| 最近记录: |