Page 1 of 1

How do I subtract from getdate()

Posted: Fri Feb 17, 2006 1:45 pm
by Ross
I am working in CST and my website is for this timezone. I am using the the function getdate() to make a current date to test database dates against.

My problem: the date I receive from getdate() is two hours ahead of CST. Can someone help me understand how to subtract two hours? My code for the variable looks like this:

Code: Select all

$curDate = date('Y-m-d', mktime(getdate()));
I read there is a function "date_default_timezone_set()" but I am not running php5 so I cannot utilize it. Is there a way to get this function working? (I don't have control over the webserver so I cannot actually load a new version of php but I have read of something called "php_compat". Any help would be appreciated. Thanks

Ross

Posted: Fri Feb 17, 2006 1:51 pm
by feyd

Code: Select all

$curDate = date('Y-m-d', gmmktime() + ($timezone * 60 * 60));
where $timezone is your timezone offset from GMT. For CST that's GMT-6. So $timezone would be -6.