Author |
Message |
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Wed Jun 19, 2002 6:37 pm (21 years, 10 months ago) |
|
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? |
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sun Jun 23, 2002 7:41 am (21 years, 10 months ago) |
|
What kind of date/time command are you using in PHP? In most of them you can just add 32400 seconds... |
________________________________
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sun Jun 23, 2002 7:54 am (21 years, 10 months ago) |
|
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. |
________________________________
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Sun Jun 23, 2002 8:05 am (21 years, 10 months ago) |
|
Presumably if I tried to enter something like '-32400' directly into a timestamp field it would just laugh at me!!
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. |
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sun Jun 23, 2002 8:10 am (21 years, 10 months ago) |
|
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". |
________________________________
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Sun Jun 23, 2002 10:33 am (21 years, 10 months ago) |
|
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"); |
|
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sun Jun 23, 2002 1:40 pm (21 years, 10 months ago) |
|
But what are you going to do about the old dates? |
________________________________
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Sun Jun 23, 2002 2:40 pm (21 years, 10 months ago) |
|
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. |
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sun Jun 23, 2002 2:50 pm (21 years, 10 months ago) |
|
Well, phpBB deals with everything except DST (you have to modify the timezone in your profile for that). |
________________________________
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Sun Jun 23, 2002 3:34 pm (21 years, 10 months ago) |
|
Don't you have to modify your profile for anything other than the board default? by the way what is DST? |
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Sun Jun 23, 2002 3:39 pm (21 years, 10 months ago) |
|
DST is Daylight Savings Time.
Right now you have to modify your profile twice a year to take it into account. |
________________________________
|
|
|
|
Justin
4WebHelp Addict
Joined: 07 Jan 2002
Posts: 1060
|
Posted:
Sun Jun 23, 2002 4:57 pm (21 years, 10 months ago) |
|
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......... |
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Sun Jun 23, 2002 5:26 pm (21 years, 10 months ago) |
|
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.... |
|
|
|
|
Justin
4WebHelp Addict
Joined: 07 Jan 2002
Posts: 1060
|
Posted:
Sun Jun 23, 2002 5:34 pm (21 years, 10 months ago) |
|
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... |
|
|
|
|
Darren
Team Member
Joined: 05 Feb 2002
Posts: 549
Location: London
|
Posted:
Sun Jun 23, 2002 5:46 pm (21 years, 10 months ago) |
|
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. |
|
|
|
|
|