Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 电影实施日期格式ISO 8601的模式_Php_Date_Schema.org - Fatal编程技术网

Php 电影实施日期格式ISO 8601的模式

Php 电影实施日期格式ISO 8601的模式,php,date,schema.org,Php,Date,Schema.org,我有这个代码,其中$arrEventDetails包含电影的发行日期。它包含的格式类似于2013年7月5日,我希望格式是2013-05-07 <meta content=" . $arrEventDetails["ReleaseDate"] . " itemprop=\"datePublished\"> 2013年7月5日是标准的日期时间格式,因此您可以使用datetime或strotime,如: $dt = new DateTime($arrEventDetails["Relea

我有这个代码,其中
$arrEventDetails
包含电影的发行日期。它包含的格式类似于2013年7月5日,我希望格式是2013-05-07

<meta content=" . $arrEventDetails["ReleaseDate"] . " itemprop=\"datePublished\">

2013年7月5日
是标准的日期时间格式,因此您可以使用datetime或strotime,如:

$dt = new DateTime($arrEventDetails["ReleaseDate"]);
echo $dt->format('Y-m-d');
或:

或:

p、 但由于电影可以在1970年之前发行,我不建议您使用
strotime
date
功能,因为它们无法处理1970年之前的年份

echo date_create($arrEventDetails["ReleaseDate"])->format('Y-m-d') . "\n";
echo date('Y-m-d', strtotime($arrEventDetails["ReleaseDate"]));