0

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.

Naina
  • 11
  • 2
  • `strtotime('15/01/1995')` returns `false` because months only go up to 12. The reason is explained in the [notes](https://www.php.net/manual/en/function.strtotime.php#refsect1-function.strtotime-notes). – Álvaro González May 30 '20 at 12:12

1 Answers1

0

Try this:

    $date="15/01/1995";
    $date=str_replace('/','-',$date);
    echo date("Y-m-d", strtotime($date));
Paras Raiyani
  • 748
  • 5
  • 10