Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Time Zone Question

Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
SpaceshipSpaceship
Watch

JYM

Established Member
Impact
64
Hi

I have a mysql database which has dates and times in it, which is displayed on my website.

Is there a way to grab the user's local machine, determine the time offset, then apply it so that all the dates on the site are according to the timezone?

This will probably require javascript or php, and I know for SURE that it works in Flash because in the actionscript i typed in a few lines and it displayed the local machine time. When I changed my computer's time, it would change in the flash file.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
the reason why the flash displays the right time is because the value you are displaying IS the local time (which in flash and javascript use the machine local time because they are apps whihc run on your computer... javascript and flash are client side programs).

However, PHP has no access to your local machine because it's a preprocessor... all code is run before being sent to the local machine, i.e. server side.

You could use IP to location technology to determine the user's timezone, than transform the dates based on the timezone difference. Be careful to watch out for locations that don't observe Daylight Savings Time!
 
0
Close
So is there a way to capture the time on the local machine, send it to the server, then have the server process it and change it accordingly so all the dates/times display correctly to that user?

Then..say..do this to each individual user (1000s...).
 
0
Close
if the user doesn't have the cookie set {
use javascript to determine user's timezone, set it into cookie, then reload page
} else {
read cookie for user's timezone and display corrected time
}
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back