09-26-2007, 10:14 AM
|
#2 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,258
Thanks: 90
|
I'd go one of two, maybe three ways at a push, in achieving this.
Method 1: Using strtotime()
Downsides: Not the fastest function in the world but gets the job done.
PHP Code:
echo date('H:i:s D M, Y', strtotime('+6 hours'));
Method 2: Using mktime()
Downsides: Long line. Uses functions inside functions which can look exceptionally messy.
PHP Code:
echo date('H:i:s D M, Y', mktime(date('H') + 6, date('m'), date('Y'), date('m'), date('d'), date('y')));
Method 3: The proper way! Using date_default_timezone_set or putenv
Downsides: Very little! Just wish this function was more heard of.
PHP Code:
putenv('TZ=US/Eastern'); // Using putenv. Good for pre PHP5. echo date('H:i:s D M, Y');
PHP Code:
date_default_timezone_set('US/Eastern'); // How to do it now we have PHP5 echo date('H:i:s D M, Y');
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|