使用php打印客户端pc日期和时间

时间:2014-05-17 05:49:46

标签: php

我正面临着这个问题。如何使用php在我的php页面上打印本地机器数据和时间。我确实尝试了很多,但没有积极的回应。如果有可能打印本地计算机数据和时间,请给我建议。

提前致谢。

1 个答案:

答案 0 :(得分:1)

我要做的一件事是,使用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
?>
相关问题