php解析日期来自一个字符串,如Sun 5月1日

时间:2014-01-05 05:26:45

标签: php parsing datetime

我试图使用date_create_from_format()从字符串中解析日期。日期字符串如下所示:Sun 5月1日 我期待这个工作

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

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

1 个答案:

答案 0 :(得分:0)

这只是格式..你需要使用它!

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