我正面临这个问题。如何打印本地机器的数据和时间在我的php页面使用php。我确实试了很多,但没有积极的回应。如果有可能打印本地电脑的数据和时间,请给我建议。
我要做的一件事是,使用JavaScript从客户端异步触发调用。像这样说:
<form method="post" action="settime.php" id="timeForm">
<input type="hidden" id="localTime" name="localTime" />
</form>
在JavaScript中:
document.getElementById("localTime").value =
(new Date()).getDate() + "/" +
(new Date()).getMonth() + "/" +
(new Date()).getYear() + " " +
(new Date()).getHours() + ":" +
(new Date()).getMinutes() + ":" +
(new Date()).getSeconds();
document.getElementById("timeForm").submit();
在服务器端,您需要做这样的事情:
<?php
$localTime = strtotime($_POST["localTime"]);
// Do something with PHP
?>