fork download
  1. <?php
  2.  
  3. $date = '04-29-2013';
  4. $time = '11:30pm';
  5.  
  6. $compound = $date . ' ' . $time;
  7.  
  8. $dt = DateTime::createFromFormat('m-d-Y h:ia', $compound);
  9. $dt->modify('+2 hour');
  10.  
  11. $newDate = $dt->format('m-d-Y');
  12. $newTime = $dt->format('h:ia');
  13.  
  14. var_dump($newDate, $newTime);
Success #stdin #stdout 0.02s 20520KB
stdin
Standard input is empty
stdout
string(10) "04-30-2013"
string(7) "01:30am"