Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a custom time in browser to test for client vs server time difference

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.

like image 784
Marcelo Avatar asked May 08 '13 19:05

Marcelo


People also ask

How do I check my timezone in Chrome browser?

Fortunately, it's easy to change the time zone displayed in Chrome. Click the Customize and Control (wrench) button and select Settings. When the Settings page appears, select the System tab. Go to the Date and Time section, pull down the Time Zone list, and select your current time zone.

How do I spoof time zones in Firefox?

Change Timezone (Time Shift) is a Firefox addon that let you easily and quickly change your timezone to a desired value and protect your privacy. Simply open addon options page and select a desired timezone from the drop down list. Once a timezone is selected, adjust the name and value fields if needed.


1 Answers

Create a new empty directory for a separate Chrome user profile. E.g. with

mkdir ~/chrome-profile 

You specify the TZ environment variable. You can see the valid timezones for example here, in column TZ.

To start Chrome, use these commands:

  • for Mac OS X: TZ='US/Pacific' open -na "Google Chrome" --args "--user-data-dir=$HOME/chrome-profile"
  • for Linux: TZ='US/Pacific' google-chrome "--user-data-dir=$HOME/chrome-profile"
like image 53
Benedikt Köppel Avatar answered Oct 08 '22 09:10

Benedikt Köppel