09-15-2008, 04:20 PM
|
#6 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Looking forwards, with more recent versions of PHP (5.3 I think) we can make use of the DateTime and DateInterval objects. For example, to add three weeks we could do the following:
PHP Code:
<?php header('Content-Type: text/plain;charset=utf-8'); error_reporting(E_ALL | E_STRICT);
date_default_timezone_set('Europe/London');
$now = new DateTime(); $future = clone $now; $interval = new DateInterval('P3W'); // or, $interval = date_interval_create_from_date_string('+3 weeks');
$future->add($interval); // or, date_add($future, $interval);
echo 'Current time: ', $now->format('jS M Y H:i:s'), PHP_EOL, 'Future time: ', $future->format('jS M Y H:i:s');
|
|
|
|