PHP: How to add a Hour to the Current Time CodeUnit 23 FEB 2010

Adding an hour to the current time turns out to be pretty easy thanks to the fantastic strtotime PHP function.

For example, should we wish to grab the hour that follows on from the current hour, we can simply make use of the code sample at the bottom of this entry.

This code snippet will echo out the following hour in 24-hour format, meaning that if the time was say currently 09:47, the script would echo out 10:

echo date('H',(strtotime("+1 hour"));

As easy as that.

Related Posts:

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.