标签: php date time
如何从PHP中的时间戳获取日期对象?
e.g。 $timestamp = 1349938801;
$timestamp = 1349938801;
答案 0 :(得分:2)
首先想到的是createFromFormat:
$datetime = DateTime::createFromFormat('U', '1349938801');
答案 1 :(得分:2)
$date = new DateTime(); $date->setTimestamp($timestamp);
http://php.net/manual/en/class.datetime.php