我正在尝试将 mm-dd-yyyy
格式的日期格式化为 yyyy-mm-dd
格式,但是,当我尝试格式化它时,结果显示为 1969-12-31
。
这是我的代码:
$custom_date = "10-13-2013";
$formatted_date = date("Y-m-d", strtotime($custom_date));
怎么了?
最佳答案
$custom_date = "10-13-2013";
$formatted_date = DateTime::createFromFormat("m-d-Y", $custom_date)->format("Y-m-d");
关于php - 格式化日期为 12/31/1969,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19350317/