Converting an invalid date format to another in PHP

I have a date in Oracle format:

22-JAN 07

And I would like to convert it to something like this:

22/01

The problem is that I cannot use the function dateas a string, which I am trying to convert does not match the valid date format.

I tried like this:

date('d/m', strtotime($row['BOOKED_DATE_FROM_1']))

But it shows:

01/01 

How can I handle this? Thank.

+5
source share
1 answer

Confirmed work

$date = DateTime::createFromFormat('d-M y', '22-JAN 07');
echo $date->format('d/m');
+13
source

All Articles