2 回答
TA贡献1831条经验 获得超9个赞
$certinfo['validFrom'] = '191105074645Z';
$date = \DateTime::createFromFormat('ymdhis',rtrim($certinfo['validFrom'], 'Z'));
$validFrom = $date->format("F d, Y");
var_dump($validFrom); // 'November 05, 2019'
die();
只需删除 Z 并从格式创建日期;-)
编辑:“Z”= UTC 如果需要,您可以强制使用时区:
$certinfo['validFrom'] = '191105074645Z';
$date = \DateTime::createFromFormat('ymdhis',rtrim($certinfo['validFrom'], 'Z'), new \DateTimeZone('UTC'));
$validFrom = $date->format("F d, Y"); // 'November 05, 2019'
var_dump($validFrom); // 'November 05, 2019'
die();
TA贡献1848条经验 获得超2个赞
这应该工作
$validFrom = date_create($certinfo['validFrom']);
echo date_format($validFrom,"F d, Y"); die();
echo $validFrom; die();
- 2 回答
- 0 关注
- 103 浏览
添加回答
举报