所以我需要将unix时间戳(以秒为单位)转换为毫秒。 这条线似乎不起作用
$unixtime = strtotime($timestamp_conv."+3 hour") * 1000;
我基本上需要一个13位数的时间戳。 我有什么想法吗?
由于
答案 0 :(得分:1)
你可以使用php的DateTime
,它更直观。
<?php
$t = new \DateTime();
$t->setTimestamp(1492498242);
$t->modify("+3 hours");
echo $t->getTimestamp()*1000;
希望它有所帮助!
答案 1 :(得分:1)
根据评论,$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;