PDA

Click to See Complete Forum and Search --> : Add an hour to time


csKanna
Oct 4th, 2008, 09:33 AM
Hello all,

I am trying to edit an existing php script. I need to know how I can add an hour to

echo current_time( 'mysql' );

The output from the following code shows differently

echo current_time( 'mysql' )+3600;

please help asap.

thanks

penagate
Oct 4th, 2008, 09:43 AM
What is 'current_time'? What does it return? What does what it returns represent?

csKanna
Oct 4th, 2008, 10:17 AM
echo current_time( 'mysql' ); will return the current system time like
2008-10-04 15:16:07
i would like to add an hour to that

I_Love_My_Vans
Oct 9th, 2008, 03:47 AM
Although I don't have the code on me right now.

You could break that date down into a UNIX timestamp, then add 3600 to it, then, format it back to its original value.

Any one know a better method of doing so?

dclamp
Oct 16th, 2008, 10:35 PM
how about a date_add (http://us3.php.net/manual/en/function.date-add.php) function? oh, how convenient :)


$date = new DateTime("2008-10-04 15:16:07 ");

date_add($date, new DateInterval("P5H"));
echo '<br />'.$date->format("d-m-Y").' : 5 Hours';