需要在Objective

编程入门 行业动态 更新时间:2024-10-25 20:19:22
本文介绍了需要在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

本文发布于:2023-11-24 12:24:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1625183.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Objective

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!