我在字符串函數新的,所以我需要一個複雜的SUBSTR和裝飾功能,該字符串:字符串DateTime對象
Wed, 28 Dec 2011 13:04:30 GMT
字符串來我總是與這種格式。我想將它轉換爲DateTime對象。任何人都可以幫助我?
我在字符串函數新的,所以我需要一個複雜的SUBSTR和裝飾功能,該字符串:字符串DateTime對象
Wed, 28 Dec 2011 13:04:30 GMT
字符串來我總是與這種格式。我想將它轉換爲DateTime對象。任何人都可以幫助我?
<?php
$date = new DateTime('Wed, 28 Dec 2011 13:04:30 GMT');
echo $date->format('r');
...打印:
Wed, 28 Dec 2011 13:04:30 +0000
你嘗試過這個'$時間=的strtotime($日期);' – Dotnet 2011-12-28 13:22:39
爲什麼你就不能使用日期時間:: createfromformat() - http://php.net/manual/en/datetime.createfromformat.php? – 2011-12-28 13:22:50
strtotime函數不接受這種格式。 datetime :: createfromformat也許可以解決這種情況。謝謝你的幫助,我現在要去看看。 – MAB 2011-12-28 13:25:58