homepage Welcome to WebmasterWorld Guest from 54.166.65.9
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Timezone Madness
Calendar dates are changing depending upon user location
neophyte




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

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

 

rainborick




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

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!

neophyte




msg:4436501
 3:57 am on Apr 3, 2012 (gmt 0)

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

neophyte




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved