@AdamSack major sites detects timezones by registered users' info, they have their own geoip database. in plus darius said that changing the time on its computer, the change is detected, so they definitely use javascript.
The JavaScript getTimezoneOffset() method is used to find the timezone offset. It returns the timezone difference in minutes, between the UTC and the current local time. If the returned value is positive, local timezone is behind the UTC and if it is negative, the local timezone if ahead of UTC.
The "Set Time Zone Automatically" feature in Windows 10 uses the location information from the Windows Location APIs, which have different levels of accuracy based on where the location information was obtained. Per the documentation on MSDN, the accuracy is as follows: GPS : within approximately 10 meters.
You can set any specific time zone using the PHP function date_default_timezone_set . This sets the specified time zone for users. Basically the users' time zone is goes to the client side, so we must use JavaScript for this.
Facebook, myspace, MSN, craigslist; all detect timezone and show times and dates correctly without ever submitting a form or reloading a page.
How do they do it? I have a pretty large site and have people publishing articles which need to display correct times (uploaded 3pm or 6pm depending on timezone).
Preloaders? Javascript? Loading the page and reloading it? My site currently has the person enter the site and upon first entry it reloads the page with updated information of their timezone through javascript. This is however a pretty annoying thing and am looking for another alternative. I know that upon loading I can send out an ajax request and then have it update everything throughout the site with the correct timezone for the user BUT if I have to click back, or reload it asks if I'd like to send the information again which is also bad. So how do they do it?
I was playing around with Facebook, changing my location on my local machine and it seemed to update the timezone every 5 minutes or so.
I am php, zend-framework based.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With