Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.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从字符串(如Sun Jan 5th)解析日期_Php_Parsing_Datetime - Fatal编程技术网

php从字符串(如Sun Jan 5th)解析日期

php从字符串(如Sun Jan 5th)解析日期,php,parsing,datetime,Php,Parsing,Datetime,我正在尝试使用date\u create\u from\u format()从字符串解析日期。日期字符串如下所示:Sun 1月5日 我原以为这会奏效 $dateFromString = date_create_from_format("D jS M", "Sun 5th Jan"); 但是不起作用,有人知道为什么吗?这只是格式而已。。你需要使用它 <?php $dateFromString = date_create_from_format("D jS M", "Sun 5th Jan"

我正在尝试使用date\u create\u from\u format()从字符串解析日期。日期字符串如下所示:Sun 1月5日 我原以为这会奏效

$dateFromString = date_create_from_format("D jS M", "Sun 5th Jan");

但是不起作用,有人知道为什么吗?

这只是格式而已。。你需要使用它

<?php
$dateFromString = date_create_from_format("D jS M", "Sun 5th Jan");
echo $dateFromString->format('Y-m-d H:i:s');

PHP版本5.4.9-4ubuntu2.4“不起作用”的确切含义是什么,您得到的是什么类型的日期?格式字符串看起来不错,但您没有指定年份,可能就是这样