onenonly Posted June 17, 2009 Share Posted June 17, 2009 I get datetime from mysql in this format 2009-06-17 13:51:01 when I get that from mysql I want to add 2 hours $row = mysql_fetch_array($result); echo $row[date]; echo $row[date] + 2 hours; ???? Quote Link to comment Share on other sites More sharing options...
947740 Posted June 17, 2009 Share Posted June 17, 2009 You forgot apostrophes. Anyway... Do strtotime first. $date = strtotime($row['date'] + 2 hours); And then reformat it using date(). Quote Link to comment Share on other sites More sharing options...
onenonly Posted June 18, 2009 Author Share Posted June 18, 2009 it doesnt work??? <?php $time = "2009-06-17 13:51:01"; $test = strtotime($time + "2 hours"); echo $test."<BR>"; echo $time."<BR>"; echo date("Y-m-j H:i:s", $test); ?> output: 1245287460 2009-06-17 13:51:01 2009-06-17 20:11:00 <-----WRONG it suppose to be 2009-06-17 15:51:01 Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 18, 2009 Share Posted June 18, 2009 Why not add 2 hours using SQL? SELECT DATE_ADD(date, INTERVAL 2 HOUR) FROM table; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.