Ios4 iOS 4.1中的NSDate格式
iOS 4.0中的[NSDate date]用于以以下格式返回日期: 2010-09-15 09:28:26+0530 但现在在iOS 4.1中,它以以下格式返回日期: 2010-09-15 09:28:26格林威治标准时间 在我的应用程序中,这会导致很多问题 有人知道如何解决这个问题吗 提前感谢,,Ios4 iOS 4.1中的NSDate格式,ios4,nsdate,nsdateformatter,Ios4,Nsdate,Nsdateformatter,iOS 4.0中的[NSDate date]用于以以下格式返回日期: 2010-09-15 09:28:26+0530 但现在在iOS 4.1中,它以以下格式返回日期: 2010-09-15 09:28:26格林威治标准时间 在我的应用程序中,这会导致很多问题 有人知道如何解决这个问题吗 提前感谢,, YPK使用感谢您的回复。我在谷歌上搜索了这个问题,在某个地方我发现NSDate在iOS 4.1中有一个bug。所以我用下面的方法解决了这个问题 - (NSString *)formattedStr
YPK使用感谢您的回复。我在谷歌上搜索了这个问题,在某个地方我发现NSDate在iOS 4.1中有一个bug。所以我用下面的方法解决了这个问题
- (NSString *)formattedStringUsingFormat:(NSString *)dateFormat
{
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:dateFormat];
[formatter setCalendar:cal];
[formatter setLocale:[NSLocale currentLocale]];
NSString *ret = [formatter stringFromDate:[NSDate date]];
[formatter release];
[cal release];
return ret;
}
我将格式传递为
[self formattedStringUsingFormat:@"yyyy-MM-dd HH:mm:ss ZZ"];
谢谢你的回复。我在谷歌上搜索了这个问题,在某个地方我发现NSDate在iOS 4.1中有一个bug。所以我用下面的方法解决了这个问题
- (NSString *)formattedStringUsingFormat:(NSString *)dateFormat
{
NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:dateFormat];
[formatter setCalendar:cal];
[formatter setLocale:[NSLocale currentLocale]];
NSString *ret = [formatter stringFromDate:[NSDate date]];
[formatter release];
[cal release];
return ret;
}
我将格式传递为
[self formattedStringUsingFormat:@"yyyy-MM-dd HH:mm:ss ZZ"];
在iOS2.x和3.x中,NSDate description/datefromstring函数返回: 2010-09-2417:30:00-0700 在iOS 4.1中,它返回以下内容: 2010-09-25 00:30:00GMT
您可以向apple提交一个bug。在iOS2.x和3.x中,NSDate description/datefromstring函数返回: 2010-09-2417:30:00-0700 在iOS 4.1中,它返回以下内容: 2010-09-25 00:30:00GMT
您可以向apple提交一个bug。显示用于获取日期的示例代码。。。更可能的问题是。。。显示用于显示日期的代码。显示用于获取日期的示例代码。。。更可能的问题是。。。显示用于显示日期的代码。