<?php
echo "本机所在的时区:".date("T")."<BR />";
echo "PHP时间戳(UNIX秒):".mktime()."<BR />";
echo "PHP时间(本地格式化后):".date("Y-m-d H:i:s")."<HR />";
?>
<script language="javascript">
<!--
var d;
function myDate(timestamp) {
d = new Date(timestamp);
var
jstimestamp =
(d.getFullYear())+"-"+(d.getMonth()+1)+"-"+(d.getDate())+"
"+(d.getHours())+":"+(d.getMinutes())+":"+(d.getSeconds());
return jstimestamp;
}
var phptimestamp = <?=mktime()?>;
var jstimestamp = myDate((phptimestamp*1000));
document.writeln("PHP传递给Javascript时间:" + phptimestamp + "<BR>");
alert("PHP传递给Javascript时间:" + phptimestamp);
document.writeln("Javascript将PHP传递来的时间乘以1000后的时间戳:" + phptimestamp*1000 + "<BR>");
alert("Javascript将PHP传递来的时间乘以1000后的时间戳:" + phptimestamp*1000);
document.writeln("Javascript自身格式化PHP传递来乘以1000后的时间戳:" + d + "<BR>");
alert("Javascript自身格式化PHP传递来乘以1000后的时间戳:" + d);
document.writeln("Javascript转换后的时间:" + jstimestamp + "<BR>");
alert("Javascript转换后的时间:" + jstimestamp);
//-->
</script>