PHP Date add 1 hour


 

PHP Date add 1 hour

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 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

 

 

Ads