I just wrote a little piece of code to show the server time in a webpage. At the moment I just have one machine so I cannot test if the code is working.
Is there a way to tell the browser to use a time configuration different from the one configured in the OS? I have used plugins for Firefox to test different locales, I wonder if there are similar options for time tests.
Thanks.
I've modified a script that opens a new instance of Chrome to also allow timezone spoofing via the 'TZ' environment variable. You can find it here: https://gist.github.com/prasadsilva/225fd0394a51e52bf62f
Old question, but I had a similar issue and I'll throw my fix in anyways.
What I did was run my server in a virtual machine, set the network settings to bridged so that I'd be able to access the server from my host OS as the client easily.
I then changed time settings in the VM so that there was whatever difference I wanted between the client and server.
This an easies way I tried to chang time zone and test it for windows 7 ^ I use
tzutil
tzutil /s "Eastern Standard Time"
and save it to suitable.bat
file e.gEastern_Standard_Time_zone.bat
and usedefault_time_zone.bat
conain your original system time zone to get it back after finishin tesing . this will change your time zone in blink . referenceUnfortunately, JavaScript is only aware of the current time zone, as it is set by the operating system. There are no facilities to let the
Date
object use a different time zone in a particular context. There are some libraries to do time zone conversions, but that won't help for what you are asking.On Linux, Mac OSX, and other *NIX systems, you can set the
TZ
environment variable. See Benedikt Köppel's answer for details.However, there is no facility for this on Windows. Some Windows programs may pick up on the TZ environment variable, but those that do will not necessarily interpret it correctly, as they aren't wired up to support IANA time zone names. More on this here and here.
On popular demand (kidding!), the explanation.
Google Chrome reads the environment variables to get the timezone its running in. Apparently all instances of Chrome share the value (not tested). In order to force a timezone, we need to a) set the environment variable to the timezone we want, b) kill all existing instances of Chrome, c) Print the current timezone to confirm, and d) Start Chrome with the intended timezone.
The below shell script is tested with OS X but should work for others too.
You're probably better off leaving your computer timezone intact and changing your server settings to reflect a timezone ahead or behind of you. This is usually pretty easy to do depending on the server you're using.