Php 将毫秒日期转换为正常日期
我从API获得了以下日期格式:Php 将毫秒日期转换为正常日期,php,date,Php,Date,我从API获得了以下日期格式: 1468102548 我正在尝试将这个日期转换成普通的人类可读格式,但是我无法让它工作 以下是我迄今为止所尝试的: $creation_date = "1468102548"; $input1 = $creation_date / 1000; $newDate_creation_date = date("Y-m-d", $input1); // Output: 1970-01-17 (It's not right) 时间戳不是以毫秒为单位的,所以将其除以1
1468102548
我正在尝试将这个日期转换成普通的人类可读格式,但是我无法让它工作
以下是我迄今为止所尝试的:
$creation_date = "1468102548";
$input1 = $creation_date / 1000;
$newDate_creation_date = date("Y-m-d", $input1); // Output: 1970-01-17 (It's not right)
时间戳不是以毫秒为单位的,所以将其除以1000会使日期倾斜
$creation_date = new DateTime('@1468102548');
echo $creation_date->format('Y-m-d'); // Outputs 2016-07-09
时间戳不是以毫秒为单位的,所以将其除以1000会使日期倾斜
$creation_date = new DateTime('@1468102548');
echo $creation_date->format('Y-m-d'); // Outputs 2016-07-09
@1468102548使用@here是很奇怪的。不管怎样,这对我来说很奇怪-我不知道为什么选择了@,但我想他们需要某种方式来表明该值是时间戳而不是字符串。@Fred ii-Boss,你使用Linux还是Windows?@HendraNucleo我的测试机器在Windows上,但我的工作服务器在*NIX;你为什么要问?@Fred ii-Fedo,cent,Deb?@1468102548使用@here这个词很奇怪。不管怎样,这对我来说很奇怪-我不知道为什么选择了@,但我想他们需要某种方式来表明该值是时间戳而不是字符串。@Fred ii-Boss,你使用Linux还是Windows?@HendraNucleo我的测试机器在Windows上,但我的工作服务器在*NIX;你为什么要问?@Fred ii-Fedo,cent,Deb?