将 UNIX 时间戳转换为毫秒 [英] Convert UNIX timestamp to milliseconds

查看:91
本文介绍了将 UNIX 时间戳转换为毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 PHP 获取 UNIX 时间戳,就像我从 JS 方法 .getTime() 中获取的一样?我似乎遇到了麻烦,因为 .getTime() 返回毫秒.我知道我必须先转换时间戳才能让 JS 读取它,但我该怎么做?

How can I use PHP to get a UNIX timestamp like what I get from the JS method .getTime()? I seem to be having trouble since .getTime() returns milliseconds. I know I have to convert the timestamps first for JS to read it, but how can I do this?

同意乘以 1000,但为什么我会得到这个?:

Agreed with the multiply by 1000, but why do I get this?:

timestamp: 1305593400
timestamp * 1000: 1.3055934E+12

timestamp: 1305612420
timestamp * 1000: 1.30561242E+12

timestamp: 1305635400
timestamp * 1000: 1.3056354E+12

timestamp: 1304901960
timestamp * 1000: 1.30490196E+12

timestamp: 1304944620
timestamp * 1000: 1.30494462E+12

推荐答案

UNIX 时间戳以秒为单位.乘以 1000.

UNIX timestamps are in seconds. Multiply by 1000.

这篇关于将 UNIX 时间戳转换为毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆