我使用PHP的功能的strtotime從一種格式轉換日期到另一個 我有以下PHP的strtotime功能
$date = "12-22-2011";
echo $newDateFormat = date("Y-m-d", strtotime($date));
// Output 1970-01-01
// But when i replace "-" with "/" I get proper output
$date = "12/22/2011";
echo $newDateFormat = date("Y-m-d", strtotime($date));
// Output 2011-12-22
爲什麼會這樣? 還是有任何其他函數接受任何東西,並轉換爲適當的日期格式?
我在http://writecodeonline.com/php/嘗試了你的例子,並得到了第一個回聲的'2019-04-03'。 –