dateFromString 和莫斯科时间
我正在使用这段代码将字符串转换为日期:
+(NSDate*)dateTexteFromString:(NSString*)someString
{
NSDateFormatter *df = [[NSDateFormatter alloc] init];
NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease];
[df setLocale:locale];
[df setDateFormat:@"EEE, dd MMM yyyy hh:mm a zzz"];
NSDate *myDate = [df dateFromString: someString];
[df release];
return myDate;
}
它对于大多数日期都可以正常工作,但是这个让我发疯:
2011 年 7 月 12 日星期二上午 12:28 MSD
(莫斯科)。我应该怎么办?还有其他像这个一样无法识别的时区吗?我无法尝试世界上所有时区:(
I'm using this code to convert a string to a date :
+(NSDate*)dateTexteFromString:(NSString*)someString
{
NSDateFormatter *df = [[NSDateFormatter alloc] init];
NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease];
[df setLocale:locale];
[df setDateFormat:@"EEE, dd MMM yyyy hh:mm a zzz"];
NSDate *myDate = [df dateFromString: someString];
[df release];
return myDate;
}
It works fine for most dates, but this one drives me crazy:
Tue, 12 Jul 2011 12:28 am MSD
(Moscow). What should I do? And is there other unrecognized timezone like this one? I can't try all timezones over the world :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 MSKS 而不是 MSD 或通过执行以下操作查找您需要的内容:
首先使用查找可用的时区名称
Use MSKS instead of MSD or find what you need by doing this:
First find the available time zone names using
Then copy the name that you want (i copied Europe/Moscow) and use this code to find the abbreviation