首页 > 解决方案 > 如何将 publishedAt 转换为日期和时间

问题描述

我得到了 publishedAt 结果,Youtube API但我想使用 php 将其转换为日期和时间,我该怎么做?

发表于:2018-08-14T14:30:02.000Z

标签: phpyoutube-api

解决方案


正如灰色所说,您可以使用 strtotime() 和 date() 来格式化日期。

$googleTime = '2018-08-14T14:30:02.000Z';
$strtotimeFormat = strtotime($googleTime);
$dateTimeFormat = date('Y-m-d H:i:s', $strtotimeFormat)
var_dump($dateTimeFormat)

输出:'2018-08-14 14:30:02'


推荐阅读