我正在尝试从NSdate转换NSString,当我尝试将字符串2011-10-10
转换为nsdate
时,它返回2011-10-09 18:30:00 +0000作为日期,我在xcode 3.2.5和模拟器中做。
我的代码
+(NSDate *)ConverStringToDate:(NSString *)str_Date
{
NSDateFormatter * lastFormatter = [[NSDateFormatter alloc]init];
[lastFormatter setDateFormat:@"yyyy-MM-dd"];
[lastFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
lastDate = [lastFormatter dateFromString:@"2011-10-10"];
return lastDate;
}
Last date不合适。请帮我解决这个问题。
指定区域设置为US,它在默认情况下弥补时间差。它可能返回一个在你的时区有效的日期(你的设备设置为,你在哪里?)这里有一个关于时区的问题