0

I have a date i.e, 12-20-14(mm-dd-yy) want to convert 2014-12-20(yyyy-mm-dd)

I try

$date='12-20-14';
echo date('Y-m-d',strtotime($date));// Output :- 1970-01-01

1 Answers1

3

The Simplest solution is

$date='12-20-14';
list($month, $date, $year) = explode('-',$date);
echo date("Y-m-d", mktime(0, 0, 0, $month, $date, $year));
Romisha Aggarwal
  • 321
  • 1
  • 13