2

How to get date format of given string, string contain a valid date I am try to import data from csv file, and that csv files are exported for backup but there are so many different type of date format and in some case when i try to convert string to date it throwing me an error

ex: 04/08/2010 10:22 am

some time this type of format throwing me error

Error 500: DateTime::__construct(): Failed to parse time string
4

3 回答 3

3

你可以只使用strtotime

echo date('Y-m-d H:i:s', strtotime('04/08/2010 10:22 am')); // output: 2010-04-08 10:22:00
于 2013-02-20T08:21:56.090 回答
2

您可以使用DateTime::createFromFormat()静态方法。

此外,您可能需要阅读以下内容:

此外,您需要使用搜索功能(页面右上角)。有很多问题涉及类似的问题。

于 2013-02-20T08:11:36.343 回答
-1

尝试这个...........

           $today = date("d/m/Y g:i a");

<?php 
    $today = date("d/m/Y g:i a");
    echo $today;
?>

你会得到这样的输出......20/02/2013 7:53 am

有关示例一,请参阅此示例链接

于 2013-02-20T07:49:10.587 回答