转换时间戳记SQL数据库来串PHP?
转换时间戳字符串,使用的setTimestamp()。比方说,以下是我们的输入,即标记-
$SQLTimestamp = 1600320600000;
我们希望下面的输出即日期字符串-
2020-09-17 05:30:00
首先,从时间戳获得秒-
$seconds = round($SQLTimestamp/1000, 0);
示例
<!DOCTYPE html>
<html>
<body>
<?php
$SQLTimestamp = 1600320600000;
$seconds = round($SQLTimestamp/1000, 0);
$PHPDateObject = new DateTime();
$PHPDateObject->setTimestamp($seconds);
echo $PHPDateObject->format('Y-m-d H:i:s');
?>
</body>
</html>输出结果
2020-09-17 05:30:00
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短