【发布时间】:2023-03-26 16:03:01
【问题描述】:
我想把 Timestamp 改成 Y-m-d H:i:s 格式
我正在尝试通过以下方式实现:
$current = date('Y-m-d');
try
{
$data = array(
'manager_id' => strval($custid),
'punch_in_time' => date("Y-m-d H:i:s", $intime),
'punch_out_time' => date("Y-m-d H:i:s", $outtime),
'in_coordinates' => strval($inlocation),
'out_coordinates' => strval($outlocation),
'status' => $punchstatus,
'create_at' => $current);
date formatted is 1488433367526 to 49136-07-30 06:42:06
$current 也在 2017 年 3 月 2 日上午 12:00:00
格式,但时间不变。
【问题讨论】:
-
strtotime 试过了吗
-
1488433367526以毫秒为单位,因此除以 1000 并转换为 int 以获得 unix 时间戳 - Demo