如何将PHP日期字符串从Y / m / d转换为Y-m-d

时间:2012-03-02 21:43:01

标签: php

我有一个当前为16/06/2012的字符串,我想将其转换为2012-06-16

我该怎么做?

2 个答案:

答案 0 :(得分:2)

$date_array = explode("/","16/06/2012");

$new_date = $date_array[2]."-".$date_array[1]."-".$date_array[0];

答案 1 :(得分:0)

date("Y-m-d", strtotime(implode("/", array_reverse(explode("/", "16/06/2012")))))
相关问题