How to get timestamp value in php which is similar

2019-03-07 02:32发布

问题:

Following javascript code gives me output like : 1314066350368

new Date().getTime();

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.

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.

回答1:

Try this:

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


回答2:

Did you try int time ( void ), Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).



回答3:

the following php results time stamp that is similar to javascript 'new Date().getTime()'

function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec) * 100;
}