Hello,
I have a time field saved in database in GMT format. I need to convert it to the visitor's local time.

Is there a way to figure out the vistor's region/time?
Should I be looking into javascript for this?
I thank you in advance for your help.

Recommended Answers

All 2 Replies

Most web sites ask you because there's no way to trust browser settings, or what the user wants to see.

You could check their IP, get geo location, and do a look up.

But if you don't mind trusting data that you shouldn't, you could use javascript: date.getTimezoneOffset()

There is 1 simple way.

1> while in registration form of user ask for time zone.
Drop down for Like GMT 5, GMT +5.30, PST ...all
store in DB in user record table .

2> Download php pear and install
when user log in pass the GMT +5.30 or PST time to variable in Pear function
you will get automatically local time of user.

read the PHP Pear
http://pear.php.net/package/PEAR/download

Hope it helps you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.