【发布时间】:2020-04-14 14:04:15
【问题描述】:
我正在使用体育 api,我正在从 api 获取比赛时间表,但时间戳是 UTC,我想根据我的本地日期搜索比赛,时间戳看起来像这样 1574463600
【问题讨论】:
-
这能回答你的问题吗? Convert timestamp to readable date/time PHP
我正在使用体育 api,我正在从 api 获取比赛时间表,但时间戳是 UTC,我想根据我的本地日期搜索比赛,时间戳看起来像这样 1574463600
【问题讨论】:
您可以使用@ 和unix 时间来创建DateTime 类。
<?php
$unixTime = 1574463600;
$date = new DateTime('@' . $unixTime);
echo $date->format('d/m/Y'); // outputs 22/11/2019
阅读DateTime这里https://www.php.net/manual/en/class.datetime
【讨论】: