0
因此,我需要将以秒为单位的unix时间戳转换为毫秒。 此行似乎不工作PHP - 从秒到毫秒的unix时间戳
$unixtime = strtotime($timestamp_conv."+3 hour") * 1000;
基本上,我需要一个13位的时间戳。 任何想法我做错了什么?
感谢
因此,我需要将以秒为单位的unix时间戳转换为毫秒。 此行似乎不工作PHP - 从秒到毫秒的unix时间戳
$unixtime = strtotime($timestamp_conv."+3 hour") * 1000;
基本上,我需要一个13位的时间戳。 任何想法我做错了什么?
感谢
根据意见,$timestamp_conv
已经是(第二)时间戳,您想要转换为(毫秒)时间戳。但是,您也会尝试添加一些偏移量(3小时)。
通过简单的算术,这将是这样的
// add the three hours: 3 hours of 60 minutes of 60 seconds each
$timestamp_conv += 3 * 60 * 60;
// convert to milliseconds base
$unixtime = $timestamp_conv * 1000;
您可以使用DateTime
从PHP,它更直观。
<?php
$t = new \DateTime();
$t->setTimestamp(1492498242);
$t->modify("+3 hours");
echo $t->getTimestamp()*1000;
希望它有帮助!
_“这一行似乎不工作” _ - 因为? – Jeff
准确地说'$ timestamp_conv'的内容是什么? – Sirko
您需要分享更多信息。 '$ timestamp_conv'的价值是什么,你的具体意思是什么*这条线似乎不工作*? – BenM