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

后端 未结 2 518
小蘑菇
小蘑菇 2021-01-19 17:25

Im using [NSDate date] to get the current time. Everything works fine if user don\'t change the time...I mean if user changed manually instead of setting it au

相关标签:
2条回答
  • 2021-01-19 17:49

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

    0 讨论(0)
  • 2021-01-19 17:49
    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);
    
    0 讨论(0)
提交回复
热议问题