Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does the javascript date object use the system clock?

Tags:

javascript

e.g., if you had:

var d = new Date();
alert(d.getTime());

is it based on the system clock? if i change the time/date on my computer's clock, am i potentially sending erroneous data back to my server?

like image 259
john Avatar asked May 06 '11 09:05

john


People also ask

Does JavaScript Date use system time?

JavaScript Stores Dates as Milliseconds JavaScript stores dates as number of milliseconds since January 01, 1970, 00:00:00 UTC (Universal Time Coordinated). Zero time is January 01, 1970 00:00:00 UTC.

Where does JavaScript Date get time from?

Given you don't need an internet connection to use JavaScript, it gets the current date & time (and by proxy, the UTC offset/locale) from the client's local environment. You can test this by changing your local clock.

Does Date use local time?

Note: It's important to keep in mind that the date and time is stored in the local time zone, and that the basic methods to fetch the date and time or its components all work in the local time zone as well.


1 Answers

This uses the system time on the client computer where this javascript is executed. So if you change the date/time on the client computer it will send the new value to the server.

like image 110
Darin Dimitrov Avatar answered Oct 01 '22 15:10

Darin Dimitrov