I have this following date format as my input
Sat 15 June
Is it possible to convert to
2013-06-15
I have used explode functions and done it. But its a long procedure though. I have also tried this:
date("Y-m-d",strtotime($input_date));
But this wont work properly...
Is there any direct function in PHP to convert into MySql date format ??? Or any built in function in php/ conversion function ????
Thanks in advance...
This outputs 2013-06-15
at my end.
<?php
$input_date = "Sat 15 June";
$formatted_date = date("Y-m-d",strtotime($input_date));
echo $formatted_date;
?>
Note that there might be some confusion about the year, since $input_date
doesn't contain a year. I think PHP will use the current year. Be careful.
Check this one,
echo date("Y-m-d",strtotime("Thu 2 May"));
If you do not supply year in strtotime() function, it will take current year as the year value.