Skip to content Skip to sidebar Skip to footer

Does Javascript Use The Local Computer Time?

This may be a dumb question, I'm 99% sure it does, but I need to be sure... does JS use the local computer's time?

Solution 1:

Yes it does use the computer's local time. To test, change your computer time and it will reflect in new Date

Solution 2:

It'll use the time on whatever computer is running the code.

In most cases, that's in a web browser on a client computer, so it'll use whatever time the web browser sees. This is most likely the computer's local time (unless the browser is doing something weird, which most don't and I've never seen).

Note that if you're using something like node.js and running server-side Javascript then it'll use the local time for that computer instead :)

Solution 3:

JS is client-side script language and as all client-side languages it can't get server time. The only way to get server time is sending request to server via AJAX (or any ActivX based tecnology).

Post a Comment for "Does Javascript Use The Local Computer Time?"