While showing date picker I'm using this code to show today's date
[_datePicker setDate:[NSDate date]];
If I change the device date to some other date the date picker's date is also changing... But I need to show today's date... How to do this
While showing date picker I'm using this code to show today's date
[_datePicker setDate:[NSDate date]];
If I change the device date to some other date the date picker's date is also changing... But I need to show today's date... How to do this
It sounds like what you want to do is to get the date from an authoritative source, like a NTP server.
Some places where you can find open source include "ios-ntp" or "NHNetworkTime", the latter of which (once building within your project) is as simple as doing "NSDate *networkDate = [NSDate networkDate];
".
And once you have that date, that's the NSDate
object you pass into your _datePicker
.
Today's date is always [NSDate date]
. If you change device date, device doesn't know anything else.
You can try http://www.ntp.org to get Internet Time
instead.
You can fetch the current Date/Time from the backend server and set it to the Date Picker.