我有以下内容:
$order_date = '04-17-2013';
echo $order_date . "\n";
$order_date = date_create($order_date);
$order_date = date_format($order_date, 'Y-m-d');
echo $order_date;
输出是:
before = 04-17-2013
after =
我以为我有那个工作,但一定是弄错了,因为它现在不工作!
使用解决方案更新
$date = DateTime::createFromFormat('m-d-Y', $order_date);
$new_date = $date->format('Y-m-d');