How to get the current time instead of device time in iOS

不羁岁月 提交于 2019-12-01 20:01:56
Silviu St

You can't find this out. The only way that goes through my mind is to take date from your server.. :(

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];                               
// display in 12HR/24HR (i.e. 11:25PM or 23:25) format according to User Settings
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];

   NSString *startTime = [dateFormatter stringFromDate:startDateTime];                   

   NSString *endTime = [dateFormatter stringFromDate:endDateTime];

   NSLog(@"User's current time %@ and end Time %@ in their preference format",startTime,endTime);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!