我正在向日历中添加一个事件,开始日期是: 2012-03-22 22:56:30 +0000
但是,当我查看日历应用程序中的条目时,它的时间是下午3:56
因此,显然与时区有关,但在查看了EKEvent的文档和谷歌搜索后,我并不知道如何处理这一问题。
发布于 2013-03-20 06:30:50
使用GMT+0存储EKEvents日期。但日历应用程序会使用您的时区本地设置显示日期。
所以我假设你在GMT-7时区,因为22:56 -7小时= 15:56 = 3:56 PM
添加本地时区日期的最好方法是使用NSDateComponents:
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setYear:2012];
[comps setMonth:3];
[comps setDay:22];
[comps setHour:22];
[comps setMinute:56];
[comps setSecond:30];
NSDate* myDate = [[NSCalendar currentCalendar] dateFromComponents:comps];如果需要,您只能使用年、月和日(小时、分钟和秒将为0)
https://stackoverflow.com/questions/9832197
复制相似问题