<script language="JavaScript"> var d = new Date(); document.write( d.getTimezoneOffset() ); </script>
运行该例子,输出(假定在北京时区):
-480
下面的例子将时间差转换为标准时区:
<script language="JavaScript"> var d = new Date(); time_zone = -d.getTimezoneOffset()/60; if( time_zone > 0 ){ time_zone = "+" + time_zone; } document.write( "本地时区为:GMT " + time_zone ); </script>
运行该例子,输出:
本地时区为:GMT +8