web-dev-qa-db-ja.com

さまざまなタイムゾーンをテストする

サイトがさまざまな場所でどのようにレンダリングされるかをテストするために、Chromeのタイムゾーンを一時的に変更する簡単な方法は何ですか?

OSX Mountain Lionでは、bashスクリプトとして次のことを試しました。

export TZ='Indian/Mauritius'

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

status.html *には次が含まれます

<!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>

dateコマンドはモーリシャスの時刻を正しく返しますが、javascriptは時刻を私のマシンの時刻としてレンダリングします

*wholeファイルを投稿したことをおologiesびしますが、考慮していない関連タグがある可能性があります

3
pufferfish

既存のすべてのChromeプロセスを最初に強制終了する必要があることが判明しました。

export TZ='Indian/Mauritius'

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

最も簡単な方法は、ローカルマシンの時刻を変更することです。これを行う方法は既に知っているはずですが、 OS X Mountain Lion:日付と時刻の設定

0
Simon Hayter