We can get the current date and time by using NSDate
but it returns the device data and time.
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSLog(@"%@",[dateFormatter stringFromDate:[NSDate date]]);
If the user has changed the date in the device then NSDate
returns the changed date. Is there any way to get the current date even though the user has changed the date?
Some may suggest to get the date from the server but i think this approach will not work for us because user can use our app in offline. After installing our app for the first time and user is in offline then we cannot check the date and time from server since user do not have any internet connectivity. We can only get the exact date once he is online.
Any suggestions will be really appreciated