从 PHP 中的时间戳创建 DateTime5.3
您如何在小于 < 的版本中从时间戳创建 DateTime5.3?
How do you create a DateTime from timestamp in versions less than < 5.3?
在 5.3 中会是:
$date = DateTime::createFromFormat('U', $timeStamp);
DateTime 构造函数需要一个字符串,但这对我不起作用
The DateTime constructor wants a string, but this didn't work for me
$date = new DateTime("@$timeStamp");
推荐答案
PHP 5 >= 5.3.0
PHP 5 >= 5.3.0
$date = new DateTime();
$date->setTimestamp($timeStamp);
为 setTimestamp
相关文章