#!/usr/bin/php <?php $start_date = "2013-12-02"; $start_time = "06:30:00"; $end_time = "06:25:00"; $start = $start_date." ".$start_time ; $end = $start_date." ".$end_time ; if ( $start > $end ) { $test = new DateTime($end); $test->modify(' +1 day'); } print $test->format('Y-m-d H:i:s'); echo "\n"; ?>