I know that there are million questions on here about converting dates in PHP, but none seems to suit my situation.
I would like to convert an array of dates that looks like this:
Array (
[0] => 1 Dec 2018
[1] => 2 Dec 2018
[2] => 3 Dec 2018
)
...into yyyy-mm-dd
format. It seems that strtotime()
cannot convert M to m, even though it should be able to do this....
The original format above is coming from a UI and cannot be changed. I therefore have not choice but to convert it.
Here is what I have:
$date // this is the original array, in '1 Dec 2018' format
$formatted_date = array();
for ($i=0; $i<count($date); $i++) {
$formatted_date[] = date("yyyy-mm-dd", strtotime($date));
}
From this, the output is
Array (
[0] => 70707070-0101-0101
[1] => 70707070-0101-0101
[2] => 70707070-0101-0101
)