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

如何将负时间戳转换为日期(PHP),php,date,datetime,Php,Date,Datetime,我想将负时间戳值转换为人类可读的值。这是我的代码: $timestamp = -30607469951; $date = new DateTime(); $date->setTimestamp($timestamp); $date->format('j/n/Y'); 我所做的只是回显格式化的$date,这就是你想要的吗 $timestamp = -30607469951; $date = new DateTime(); $date->setTimesta

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

$timestamp = -30607469951;   

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

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

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

$timestamp = -30607469951;

$date = new DateTime();

$date->setTimestamp($timestamp);

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

首先,这个负时间戳应该是什么日期?未来回到恐龙时代?@Rizier123它被证明是1000年第2个月第1天,除非你使用64位PHP,否则这是行不通的。该值大大超过了32位PHP所能表示的值。您已经在这样做了。允许使用负时间戳。也许改变你的格式是你不喜欢的。马克,你是对的。有没有不改变体系结构的解决方案?