0

I want to convert DOMTimeStamp from Geolocation in PHP in order to save it in DATETIME in the database. How can I accomplish this?

4

1 回答 1

6

这只是一个以毫秒为单位的时间戳。只需将其转换为秒,然后使用 PHP 内置的日期/时间功能进行转换:

$timestamp = floor($domtimestamp / 1000); // Get seconds from milliseconds
$datetime = new DateTime('@'.$timestamp);
echo $datetime->format('Y-m-d H:i:s');
于 2014-04-23T13:10:57.243 回答