Using PHP to Match a Javascript Timestamp

后端 未结 3 1073
面向向阳花
面向向阳花 2021-01-23 04:25

Alright when I do the code:


You get the Unix t

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-23 05:05

    What you are looking for is millisecond time in PHP. To accomplish this you need to use a combination of the microtime function and some multiplication.

    microtime when passed true as its first parameter will return the current time as the number of seconds since the Unix epoch to the nearest microsecond.

    To convert the value into an integer value of the number of milliseconds since the Unix epoch you must multiply this value by 1000 and cast to an integer.

    So:

    $milliseconds = (int)(microtime(true) * 1000);
    

提交回复
热议问题