Server time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Server time

Post by irealms »

I'm using the time() function to create the time a message is entered but it's coming out 1 hour ahead, i'm on GMT time so not sure why it's doing this any ideas?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

time() gives you the time that the server has set. Either change the server time, or accept that time() will give you gmt+1 and work to this value or remove 3600 from the result it gives you.
Simon
Forum Newbie
Posts: 12
Joined: Sun Dec 12, 2004 11:36 pm

Post by Simon »

Hmmm.... I pretty certain that time() produces the GMT timestamp. Most of the other date functions do actually return the server's date/time by correcting the timezone (unless you use gmdate() etc.), I've been confused by this in the past. Either you're using date() or another date function to actually display the timestamp readibly and it's converting it for you, or your server timezone is set incorrectly. Perhaps daylight-savings could somehow be affecting it too.

See: http://www.php.net/time

< Simon >
Post Reply