We help IT Professionals succeed at work.

PHP time question

elepil
elepil asked
on
When I key this in PHP:

echo strftime("%Y-%m-%d %H:%M:%S", time());

Open in new window


It somehow comes out 8 hours too much.

Can anyone tell me if I'm doing something wrong?

Thanks.
Comment
Watch Question

Top Expert 2013
Commented:
What timezone are you in.  If you do not specify a time zone it defaults to UTC.  So if you are on the US west coast that would be an 8 hour difference.



Cd&

Author

Commented:
Cd, that was it. I changed the date.timezone to America/Los_Angeles, restarted the server, and it was fine.

Thanks for your help!
Top Expert 2013

Commented:
I do it almost every time I do a new site; forget to set the time.

Cd&
Most Valuable Expert 2011
Top Expert 2016

Commented:
No points for this, but just a thought... Why not standardize on UTC?  Then localize your time for each of your clients, based on where they are located.  Everyone can be happy, no matter where they live :-)

Author

Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for elepil's comment #a40659662

for the following reason:

Hmm... thought I already closed this. Sorry for the delay.

Author

Commented:
Thanks!