PDA

View Full Version : Calendar dateline_to wrong date


K2_02
04-20-2009, 08:25 PM
I'm trying to pull the events from the calendar and display them on a custom PHP page. Here is my query:

SELECT eventid,event,dateline_from,dateline_to,title,dst FROM vb_event WHERE dateline_from >= ".$iTimeStamp." AND dateline_from <= ".($iTimeStamp+$addTime)." ORDER BY dateline_from ASC

Where iTimeStamp is today's date and iTimeStamp+addTime is so time in the future (30, 60 days, etc).

The date is coming out one day off on SOME events but not all. Even when checking the unix timestamp using a converter - the timestamp is wrong. How do I compensate for this or can someone please shed some light on how VBulletin stores these dates?

Dismounted
04-21-2009, 09:22 AM
All timestamps are in Unix Time - there is nothing really "special" about them.

K2_02
04-21-2009, 01:16 PM
After a fresh nights sleep I was able to track down my problem. I wasn't compensating for the GMT offset properly. We're GMT-5. So for an event that was scheduled for 7:30pm on 5/10 would display as 5/11. Added in the correct offset, -18000 (3600*utc field in the DB), and everything works like a champ.

Dismounted
04-22-2009, 07:08 AM
Make sure you store the timestamp in UTC, and don't add timezone differences. Only compensate when displaying. :)