Mobile app version of vmapp.org
Login or Join
Sue5673885

: Test different timezones What is a simple way to temporarily change the timezone in Chrome so as to test how a site renders for different locations? On OSX Mountain Lion, I've tried as bash

@Sue5673885

Posted in: #Html #Internationalization #Javascript

What is a simple way to temporarily change the timezone in Chrome so as to test how a site renders for different locations?

On OSX Mountain Lion, I've tried as bash script with:

export TZ='Indian/Mauritius'

date
open /Applications/Google Chrome.app ~/status.html


where status.html * contains

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Time zone test</title>
</head>
<div id="local"></div>
<div id="offset"></div>
<script>
document.getElementById('local').innerHTML = "The local time is " + (new Date()).toLocaleString();
document.getElementById('offset').innerHTML = "Local offset:" + (new Date()).getTimezoneOffset();
</script>
</body>
</html>


The date command correctly returns Mauritius time, but the javascript renders the time as being my machine's time

* apologies for posting the whole file, but there might be relevant tags I haven't considered

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Sue5673885

2 Comments

Sorted by latest first Latest Oldest Best

 

@Marchetta884

Turns out one needs to kill all existing Chrome processes first.

export TZ='Indian/Mauritius'

killall Chrome
date
open /Applications/Google Chrome.app ~/status.html

10% popularity Vote Up Vote Down


 

@Turnbaugh106

Well the easiest method would be just to change the time on your local machine, I'm sure you know how to do this already but: OS X Mountain Lion: Date & Time preferences.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme