Click to See Complete Forum and Search --> : working with date \ time simple question :-)


LeighRogers
03-27-2007, 06:37 AM
Afternoon all :-)

I've built a function that records what is downloaded, and by who'm on my website. The last thing that is left is to record the date.

I have it recording fine & I calculate the date using


$date = date("Y-m-d G:i:s");


however, the time returned is 1hour ahead of me (assuming thats because of the locality settings on my service provider) How can I adjust the value returned by


$date = date("Y-m-d G:i:s");


To take this into account or alternatively amend it after its returned and just before i submit it to the database?

Many thanks in advance.
Leigh

aj_nsc
03-27-2007, 06:55 AM
Set the timezone before you do your date calculations.

Something like this:

//this is my timezone
date_default_timezone_set("America/St_Johns");


For a complete list of timezone abbreviations, check out php.com

bokeh
03-27-2007, 07:05 AM
There are lots of ways. Maybe:$date = date("Y-m-d G:i:s", time()-(60*60));

LeighRogers
03-27-2007, 07:09 AM
Thank you very much!!

$date = date("Y-m-d G:i:s", time()-(60*60));

worked perfectly :-)

Thanks again - Much appreciated!