Dave wrote:
Well if the time is being captured on the server side and I'm adding 2 hours
to that in my code - how would day light savings come into play?
"michelle" <miki@spam_me.net> wrote in message
news:hb********************@comcast.com...
Dave wrote:
Hey folks,
I'm moving from ASP to PHP and I must say that on using this for only a
day it is MUCH simpler to get things going. Already have made a VERY
basic blog site for myself in a very short period of time. Anyhow I have
a datetime issue:
On my blog site I capture the date like this: $date=date("Y-m-d g-i-s");
When I display this date later it is 2 hours being my time. I'm guessing
that the servers are somewhere in the mid west - I am in the EST time
zone. Can anyone help me correct this so that I either capture the time
proplerly or display it in my zone?
Thanks,
Dave
Dave,
This code also accounts for daylight savings time for my time offset which
is -8 (Pacific):
echo gmdate('Y-m-d g:i s', time() + 3600*(-8 + date('I')))
Why change your code twice a year?
Miki
The safest way to do this is to use the gmdate() function, which doesn't
take into account daylight savings time...it is simply GMT. You can
do it your way if you are positive that your server will not move. But
my suggestion will make your code more portable - if you move it to
another server. If you do move to another server in another time zone
you will have to rewrite this portion of code...and if you use this
thinking throughout your work there will be more changes, too. The way I
suggest is a simple set it and forget it method...but you can do it your
way if you like.
Miki