Welcome to WebmasterWorld Guest from 54.198.222.129

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Timezone Madness

Calendar dates are changing depending upon user location

     
4:41 am on Mar 26, 2012 (gmt 0)

10+ Year Member



Hello All -

I've built a resort booking system that includes a calendar date picker. The resort is located in the Philippines. When the calendar date picker is generated, each date references a UNIX timestamp.

If a user (requesting a room from anywhere within the Asia/Manila timezone) chooses a check-in date from the calendar of March 15 (for example) and a check-out date of March 19, everything works as spec'd.

However, if a user from the States chooses the same check-in and check-out date, the dates specified both on-screen (in a reservation status div) and in their request confirmation March 14 and March 18 respectively (one day behind).

I think that I know what the problem is: since the php date function requires that the date.timezone be set, each time a user is served a new page, the timezone I've specified (through a config file) is set to date.timezone = Asia/Manila (GMT +8). Since the states is "behind" the Philippines by 16 to 18 hours I'm assuming this is the problem.

IF THIS IS THE GLITCH that's causing the "one day behind" anomaly, is there a way to automatically reset the timezone specification to reflect the USERS current timezone?

If this isn't the problem, can someone give me some insight in how to track down and solve this issue?

Huge appreciation in advance for any guidance.

Neophyte
2:58 pm on Mar 26, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think your problem lies elsewhere. The time/date values your site generates with PHP is the same regardless of the user's geo-location and local time. It would only be if you're using a date picker generated by JavaScript that the user's local time is involved, in which case you can use getTimezoneOffset() to normalize the data. Good luck!
3:57 am on Apr 3, 2012 (gmt 0)

10+ Year Member



Rainborik -

Sorry for the late reply; been out of the country. Thanks very much for the hint...

The date picker is generated via PHP, however it does also have some javascript (jquery) which gets the date (unix timestamp) clicked.

Will report if getTimezoneOffset() works.

Thanks very much!

Neophyte
1:57 am on Apr 16, 2012 (gmt 0)

10+ Year Member



Hello Rainborik -

Was trying to use getTimezoneOffset() to solve my problem but still no love. I have coded a work around that does display the correct date no matter what timezone the users system clock is set to however so, for now, all is well.

Thanks very much for your input.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month