How to get current time instead of device time in iOS

Im using [NSDate date]to get the current time. Everything works fine if the user does not change the time ... I mean, if the user changed manually, instead of automatically setting it. Then how can I get the original time?

Thanks!

+4
source share
2 answers

You cannot find out. The only way that comes to my mind is to get the date from your server ..: (

+2
source
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 current time %@ and end Time %@ in their preference format",startTime,endTime);
0
source

All Articles