Home Tutorial Php Phpdate PHP Date add 1 hour

 
 

PHP Date add 1 hour
Posted on: August 27, 2009 at 12:00 AM
In this example code we will show you how you can add 1 hour to a date in PHP code. In this session you will be learn how you can add one hour to a date object.

In the following example code we are showing how you can add one hour to a date object.

<?php

//This PHP Example code shows how to add one hour to a date object

$todayDate = date("Y-m-d g:i a");// current date
$currentTime = time($todayDate); //Change date into time

//echo "<br>".$currentTime;
//Add one hour equavelent seconds 60*60

$timeAfterOneHour = $currentTime+60*60;

/echo "<br>".$timeAfterOneHour;
echo "<br>Current Date and Time: ".date("Y-m-d H:i:s",$currentTime);
echo "<br>Date and Time After adding one hour: ".date("Y-m-d H:i:s",$timeAfterOneHour);

?>

Output of the program:

Current Date and Time: 2009-08-27 10:55:48
Date and Time After adding one hour: 2009-08-27 11:55:48

 

 

Related Tags for PHP Date add 1 hour:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.