-1

I have the following php variable set to a date:

 $old_date = 2013 - 11 - 1;

and I'd like to convert the date to 11-1-2013 and assign it to the variable $new_date. Is there an easy way to do this? Thanks!

What I have so far id ...

 $old_date = 2013 - 11 - 1;
 $old_date_timestamp = strtotime($old_date);
 $new_date = date('m-d-y H:i:s', $old_date_timestamp); 

 echo $new_date;

this works but it round to the next day so what gets echoed out is 11 - 2 -2013

matt tuman
  • 83
  • 1
  • 5
  • 14

1 Answers1

3
$old_date = '2013-11-1';
$new_date = date('n-j-Y', strtotime($old_date));
Telshin
  • 340
  • 1
  • 5