如何将负时间戳转换为日期(PHP)

时间:2015-07-10 21:36:38

标签: php date datetime

我想将负时间戳值转换为人类可读值。这是我的代码:

$timestamp = -30607469951;   

$date = new DateTime();    
$date->setTimestamp($timestamp);

$date->format('j/n/Y');

1 个答案:

答案 0 :(得分:1)

我所做的只是回显格式化的$date,这是你想要的吗?

$timestamp = -30607469951;

$date = new DateTime();

$date->setTimestamp($timestamp);

echo $date->format('Y-m-d');