【发布时间】:2014-04-20 17:31:38
【问题描述】:
为了显示构建日期,我使用了以下代码:
NSString *compileDate = [NSString stringWithUTF8String:__DATE__];
NSDateFormatter *df = [[NSDateFormatter alloc]init];
[df setDateFormat:@"MMM d yyyy"];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[df setLocale:usLocale];
NSDate *date = [df dateFromString:compileDate];
[df setDateFormat:@"yyyy"];
self.backgroundColor = [UIColor clearColor];
self.textAlignment = NSTextAlignmentCenter;
self.text = [NSString stringWithFormat:@"© Copyright 2009-%@ Version %@ %@", [df stringFromDate:[NSDate date]], VERSION, date ];
今天是 2014/03/15,它返回 2014/03/14
我的设备设置在美国位置。我找不到问题所在!
注意:编译时间总是20:30:00 +00:00!
我该如何解决?
【问题讨论】:
-
是的,我做到了,而且效果很好。
-
其实所有的答案都是有帮助和可以接受的