Reputation: 777
Does someone know how to get an actual country date without any possibility for the user to fake it ? This date is supposed to perform security check and I don't know if using new Date() is safe ? Can we modify the date via phone settings to fake the result of new Date() ?
Upvotes: 0
Views: 184
Reputation: 777
I just found this question How to get Online Current Date and Time in React Native
where someone is giving this API https://timezonedb.com/api
Upvotes: 0
Reputation: 1075159
You cannot trust the date on the device, particularly if you're using the date for gatekeeping as then the user has a particular incentive to make the date on the device incorrect.
Instead, if you really need to (mostly) trust the date, you need to query it over the network from somewhere not under the user's control, such as NIST.
Upvotes: 2