Time Offset

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
Bob Norris
Forum Newbie
Posts: 8
Joined: Wed Sep 08, 2004 3:01 pm

Time Offset

Post by Bob Norris »

Hello,

Can anyone please tell me how to offset the time in this code? I need it to be -6 hours from local time

Code: Select all

$msgcontent = &quote;Local time : $tgl\n\nThe addition from $vname
Thank you so much!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh... where's $tgl from?
Bob Norris
Forum Newbie
Posts: 8
Joined: Wed Sep 08, 2004 3:01 pm

Same

Post by Bob Norris »

THe $tgl is server time I think,, and its in the uk Sorry I hope thats what you ment
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

kinda need to know what $tgl is and how it's set in order to tell you how to change it. Unless you want to create your own version, in which case:

Code: Select all

$tgl = gmdate('Y-m-d H:i:s', time() - (6 * 60 * 60));
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Unfortunately, the above doesn't take into account DST. Like if you do UTC+1 (Germany), right now it will say 1 am, but Germany is in CEST right now, and the time is 2 am . If the server resides in the timezone you wish to print the time for, you can know if DST is on by the output of date("I") though. But I don't think that is what you are wanting to do.
Bob Norris
Forum Newbie
Posts: 8
Joined: Wed Sep 08, 2004 3:01 pm

Same Topic

Post by Bob Norris »

Thank you,

What I'm trying to do is,, my form when some one enters information it puts a time stamp on it, The server is in the UK and I am in the US (EST) I would like the form to show EST so I need to offset it -5 hours. Thanks in advance


Bob
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Right, that code will work, except by Sunday the 3rd of April I think, it should be -4, cause EST will be EDT for daylight time, one hour ahead.
Post Reply