Home Tutorial Php Phpdate PHP Date add 1 hour

 
 

PHP Date add 1 hour
Posted on: August 27, 2009 at 12:00 AM
Advertisement
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

 

 

Advertisement

Related Tags for PHP Date add 1 hour:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 27, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com