我的系统的日期时间是26 5月22:55,但是当我使用[NSDate date]获取日期时,我的日期时间是27 5月02:35
是不是因为时区的原因?
如果是如何解决这个问题,当我得到日期时间,给我我的系统的日期,而不检查时区
发布于 2012-05-27 14:14:14
NSLocale* currentLocale = [NSLocale currentLocale];
[[NSDate date] descriptionWithLocale:currentLocale]; 或使用
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
// or @"yyyy-MM-dd hh:mm:ss a" if you prefer the time with AM/PM
NSLog(@"%@",[dateFormatter stringFromDate:[NSDate date]]);https://stackoverflow.com/questions/10772033
复制相似问题