我正在尝试使用 NSDateFormatter 将保存的日期更改为山区标准时间,但它似乎不起作用。
它正在向控制台输出“currentDate: 2013-02-22 23:20:20 +0000 date with date formatter: other 2000-01-01 07:00:00 +0000”。
看起来该字符串没有正确创建,但我似乎以与正常调用它相同的方式调用它。
建议?
NSTimeZone * mtnTimeZ= [NSTimeZone timeZoneWithAbbreviation:@"MST"];
NSDate *currentDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setTimeZone:mtnTimeZ];
NSString * timeZ = [dateFormatter stringFromDate:currentDate];
NSDate * newDate = [dateFormatter dateFromString:timeZ];
NSLog(@"currentDate: %@ string With dateFormatter: %@ date made from string %@", currentDate, timeZ, newDate);