Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert not valid 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, i can not use the date function as the string I am trying to convert doesn't match any valid date format.

I was trying it like this:

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

But that shows:

01/01 

How could i deal with this? Thanks.

like image 907
Alvaro Avatar asked Dec 16 '22 14:12

Alvaro


1 Answers

Confirmed working

$date = DateTime::createFromFormat('d-M y', '22-JAN 07');
echo $date->format('d/m');
like image 196
John Conde Avatar answered Dec 27 '22 07:12

John Conde