Date.now () changes when we change the native date of the mobile

Like i said in the title i got a problem with date.now()

When someone change the native date of the mobile it also changes the actual date … However, I have to test the difference between the date of now and the last date that this person made a specific feature (for a feature that only available 10 times a day).

So I thought about the date of firebase server but this date is not recovered directly … It only works when writing to the database (firebase.database.ServerValue.TIMESTAMP)

Hi @EnzoDLP,

That’s the expected behavior. Date.now() returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC based on the system’s date and time. If you change the date/time, the function returns what the OS tells the browser.

You can use a 3d party API if you need a source of truth for the current date & time, like World Clock API or World Time API, or your own Firebase Cloud Function.

Best,
Rodrigo

1 Like

Clear and precise, thank you very much!

1 Like