KDX2
KDX2

Reputation: 1033

From where javascript fetches date

I know that there're lots of topics on how js's date() works but I miss one bit. I'm working on a small web app which has a server and clients. Each client may run on Windows or Linux (mac... etc.). The problem is that afaik, if you are a Windows user then, your PC's date will be fetched through a worldclock server, somewhere, it's pbly Microsoft's BUT if you're running Linux, then your date/time are being computed on your computer. So, does js's date() fetch a date (or time) requesting to a server, just like windows does, or it just looks at a given pc's date, reads it and displays it? To me this is of great importance as I've a dual-bootable computer and every switch from linux to windows causes time inaccuracy, meaning that I've to take into account clients' wrong date/time if JavaScript reads it from one's pc. Put in other words, does JS's date() fetch the date and time information requesting separate server by giving it location information for the user based on say, IP?

Upvotes: 0

Views: 37

Answers (1)

Quentin
Quentin

Reputation: 944568

The Date function in the browser just uses the system clock. This is true regardless of operating system.

The system clock may be set manually, via an NTP server, via GPS or mobile phone signal. This is true regardless of operating system.

I've a dual-bootable computer and each switch from linux to windows causes time inaccuracy

This is likely caused by the time zone being incorrectly configured on one or both of your operating system configurations. There is no realistic way to account for that sort of misconfiguration when writing software.

Upvotes: 2

Related Questions