4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Timestamps in different timezones...
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Wed Jun 19, 2002 6:37 pm (15 years, 6 months ago) Reply with QuoteBack to Top

I am in the process of moving my site from a UK based server to one 9 hours ahead, my problem is this:

My Guest Book, as an example, records the time and date somebody signs it using a timestamp field in MySQL. Obviously when this is done now the timestamps are 9 hours ahead of GMT.

Is there a way of offsetting the timestamp when it is recorded?

I don't want to have to adjust the times when I pull them from the database and display them as this will make all my existing records wrong.

Any ideas or tips?
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Jun 23, 2002 7:41 am (15 years, 6 months ago) Reply with QuoteBack to Top

What kind of date/time command are you using in PHP? In most of them you can just add 32400 seconds...

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Jun 23, 2002 7:54 am (15 years, 6 months ago) Reply with QuoteBack to Top

Hmmm... Never thought about that. I was thinking of adding the seconds to all dates, but then you'd have to get the script to add the new dates with English time.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Jun 23, 2002 8:05 am (15 years, 6 months ago) Reply with QuoteBack to Top

Presumably if I tried to enter something like '-32400' directly into a timestamp field it would just laugh at me!! Laughing

I think what I'm going to have to do is supply the correct time when I insert the data into the database rather than giving it a NULL value to get get the current Timestamp.
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Jun 23, 2002 8:10 am (15 years, 6 months ago) Reply with QuoteBack to Top

What I meant was that in PHP, the time/date commands can receive a parameter to tell them which date/time you want to display, and you can also add to it "-32400".

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Jun 23, 2002 10:33 am (15 years, 6 months ago) Reply with QuoteBack to Top

Yeah, I know what you were saying, I was just wondering whether there was a way to influence a timestamp directly in the SQL by supplying it with the offset rather than a date.

Anyway in the end I have just used the following to create my timestamp, no need to add a certain amount of seconds.
Code:
$gmdate = gmdate("YmdHis");
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Jun 23, 2002 1:40 pm (15 years, 6 months ago) Reply with QuoteBack to Top

But what are you going to do about the old dates?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Jun 23, 2002 2:40 pm (15 years, 6 months ago) Reply with QuoteBack to Top

They were recorded as GMT times and reading them back out of the database doesn't change that.

There would have only been a problem if I'd have started applying an offset to the output. The times recorded from the new server would have been fine but the old ones would have been wrong. I think that makes sense.

Anyway at the end of the day I guess its not really any great problem if time someone signed a guestbook is a few hours out. And besides we get visitors from around the world so the times won't be correct for them, anyway.
The only place on the site where dates are essential is on the forum and phpbb2 deals with that.
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Jun 23, 2002 2:50 pm (15 years, 6 months ago) Reply with QuoteBack to Top

Well, phpBB deals with everything except DST (you have to modify the timezone in your profile for that).

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Jun 23, 2002 3:34 pm (15 years, 6 months ago) Reply with QuoteBack to Top

Don't you have to modify your profile for anything other than the board default? by the way what is DST?
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Jun 23, 2002 3:39 pm (15 years, 6 months ago) Reply with QuoteBack to Top

DST is Daylight Savings Time.

Right now you have to modify your profile twice a year to take it into account.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Jun 23, 2002 4:57 pm (15 years, 6 months ago) Reply with QuoteBack to Top

Darren wrote:
I am in the process of moving my site from a UK based server to one 9 hours ahead, my problem is this:

I think your on the same server as me, but is it just me, or has the time difference changed now, as it always used to be 9 hours, but I have a feeling it's changed 'cos I had to change my PHP code as it was giving the wrong dates.........
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Jun 23, 2002 5:26 pm (15 years, 6 months ago) Reply with QuoteBack to Top

I just run the following at : 18:18 BST
Code:
$gmdate = gmdate("Y m d - H:i:s");
echo "$gmdate<br>";

$date = date("Y m d - H:i:s");
echo "$date<br>";

And this was the result:
2002 06 23 - 17:20:15
2002 06 23 - 13:20:15

Whats going on? it would appear that that the server has gone from being 9 hours ahead to 4 hours behind....
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Jun 23, 2002 5:34 pm (15 years, 6 months ago) Reply with QuoteBack to Top

Darren wrote:
I just run the following at : 18:18 BST
Code:
$gmdate = gmdate("Y m d - H:i:s");
echo "$gmdate<br>";

$date = date("Y m d - H:i:s");
echo "$date<br>";

And this was the result:
2002 06 23 - 17:20:15
2002 06 23 - 13:20:15

Whats going on? it would appear that that the server has gone from being 9 hours ahead to 4 hours behind....

Hmmmm, I was thinking the same, I was going to send in a ticket or contact support, but decided it's too small to worry about, I may do it if it changes again though. May have been changed to American Time Zone...
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Jun 23, 2002 5:46 pm (15 years, 6 months ago) Reply with QuoteBack to Top

It seems the best way would be to keep any dates and times independent from the server time. Certainly gmdate() seems to be an advantage here as I didn't even notice the clock had changed. Where as adding or subtracting from the server time relies on the server's clock remaining consistent.
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.071747 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme