本文介绍了需要在Objective-C中获得中心时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有需要获取当前时间(CST)的应用程序.我正在尝试使用以下代码,但NDate与GMT相同:
I have app where i need to get the current time (CST). I'm trying to use the following code but the NDate is the same as GMT:
NSDate* date = [NSDate date]; NSLog(@"Time is %@", [date description]); [NSTimeZone setDefaultTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"CST"]]; NSDate* nDate = [NSDate date]; NSLog(@"Central time is%@", [nDate description])推荐答案
除了时间本身没有时区之外,您还必须添加一个日历来设置与时区相关的日历,如我所描述的此处,您不应使用此处.
Beside the fact that the time has not timezone itself, but you have to add a calendar to set it in relation to a time zone as I described here, you should not use a tz abbreviation as described here.
更多推荐
需要在Objective
发布评论