Add hours in DateTime in PHP

In PHP, you can get the current Date and Time by using the function date():

date()     OR   date('Y-m-d H:i:s')

 

Manipulating Date/Time is very easy in PHP and you can easily add something to this, like add hours, days, minutes using function strtotime():

date('Y-m-d H:i:s', strtotime('4 minute'));
date('Y-m-d H:i:s', strtotime('6 day')); 
date('Y-m-d H:i:s', strtotime('1 hour'));

 

Also, a short cut way of doing the same is using the + operator. Like the following: 

$timestamp = strtotime('4:29') + 60*60// Adding One Hour
$time = date('H:i', $timestamp);
echo $time;// This will print 5:29