I have a date in an input
15/01/1995
.But, I want to save this date in this format 1995-01-15
.
I tried this code
$date_format = date("Y-m-d", strtotime($Data['date']));
but, the output is 1970-01-01
which is wrong.
I have a date in an input
15/01/1995
.But, I want to save this date in this format 1995-01-15
.
I tried this code
$date_format = date("Y-m-d", strtotime($Data['date']));
but, the output is 1970-01-01
which is wrong.
Try this:
$date="15/01/1995";
$date=str_replace('/','-',$date);
echo date("Y-m-d", strtotime($date));