• support@answerspoint.com

Adding 1 hour to time variable


This simple thing has wasted hours of my time trying to get it working, still havnt worked it out...

i have

$time = '10:09';

I want to add an hour to that...

So, I've tried:

$time = strtotime('+1 hour');

strtotime('+1 hour', $time);

$time = date('H:i', strtotime('+1 hour'));

None of the above worked.

Can you guys help me out?




Worked for me..

$timestamp = strtotime('10:09') + 60*60;

$time = date('H:i', $timestamp);

echo $time;//11:09
  • answered 7 years ago
  • Gul Hafiz


You can do like this

    echo date('Y-m-d H:i:s', strtotime('4 minute'));
    echo date('Y-m-d H:i:s', strtotime('6 hour'));
    echo date('Y-m-d H:i:s', strtotime('2 day'));
  • answered 7 years ago
  • Gul Hafiz


You can use:

$time = strtotime("10:09") + 3600;
echo date('H:i', $time);

Or date_addhttp://www.php.net/manual/en/datetime.add.php

  • answered 7 years ago
  • B Butts

Your Answer

    Facebook Share        
  • asked 7 years ago
  • viewed 1986 times
  • active 7 years ago

Best Rated Questions