开发者

How to get exactly real current date

开发者 https://www.devze.com 2023-03-26 05:03 出处:网络
I know you guys might be saying that this question is very common but actually I\'m referring to the actual current date and time:

I know you guys might be saying that this question is very common but actually I'm referring to the actual current date and time:

Let say today is 1st of August,12pm and no matter how the user change their phone date and time, I will still know today is 1st of August, 12pm...

Anyone k开发者_运维技巧now how can I do that?


You can get the real date and time from an NTP server, but this assumes that you have internet access.


If the user changes their phone date and time, then you will get that date and time... since NSDate gets its value from the iOS. If you want it to return the actual time per time zone, you will have to set up a small Web Service or something that returns the time for that particular time zone.


NSDate *currentDate = [NSDate date];

Now currentDate will have the current date & time when this code is executed.

0

精彩评论

暂无评论...
验证码 换一张
取 消