Monday, December 19, 2011

add or subtract time in php


<?php
date_default_timezone_set('Asia/Dubai');
$rightnow = date('d-m-Y H:i:s');
echo "The time right now is $rightnow";
echo "<br />";
$after = 1200 + time();
$timeafter = date('d-m-Y H:i:s',$after);
echo "The time after 20 minutes will be $timeafter";
echo "<br />";
$before = time() - 1200;
$timebefore = date('d-m-Y H:i:s',$before);
echo "The time 20 minutes ago was $timebefore";
?>

No comments:

Post a Comment