我想使用 PHP 和 JavaScript 来回显当前的本地日期(而不是服务器日期)。
我的代码如下:
<?php
$year = '<script type="text/javascript">
var date = new Date();
var year = date.getFullYear();
document.write(year);
</script>';
$month = '<script type="text/javascript">
var date = new Date();
var month = date.getMonth();
var monthName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "november", "December");
var curMonth = monthName[month];
document.write(curMonth);
</script>';
$day='<script type="text/javascript">
var date = new Date();
var day = date.getDate();
document.write(day);
</script>';
$curDateString = $day . " " . $month . " " . $year;
$curDate = date('m/d/y', strtotime($curDateString));
echo $curDate;
?>
它总是返回01/01/70
。
我究竟做错了什么?