如何在 php 中获取时间戳值,类似于 javascript 中的 getTime()

问题描述:

以下 javascript 代码给了我这样的输出:1314066350368

Following javascript code gives me output like : 1314066350368

new Date().getTime();

我想在 PHP 中生成类似的时间戳以获取服务器的时间戳.请建议我如何在 PHP 中执行此操作,以便我的 PHP 代码生成完全相似的时间戳.

I would like to generate similar timestamp in PHP in order to get server's timestamp. kindly suggest me how to do it in PHP so my PHP code will generate exactly similar timestamps.

附言我知道 PHP 中的 time() 和 microtime() 函数.但我期待得到与上面提到的类似的输出.

P.S. I do know about time() and microtime() functions in PHP. But i am looking forward to get similar outputs as i have mentioned above.

试试这个:

<?php
echo microtime(true)*1000;
?>