Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to detect a users date/time locale in PHP?

Posted on 2008-10-26
2
Medium Priority
?
944 Views
Last Modified: 2013-12-13
Is it possible to detect a users locale in PHP so that I can display a date in their country format.  

i.e. if a user from the US visits the site they see the date in mm/dd/yyyy format, and if someone from the UK visits the site then they see it in dd/mm/yyyy.  

ASP.Net does this automatically, I'm wondering if it is possible to do it in PHP (by reading their browser settings, not loooking up their IP addres).  
0
Comment
Question by:DelphiMan7
2 Comments
 
LVL 9

Expert Comment

by:Shahzad Fateh Ali
ID: 22808343
Hi DelphiMan7,

You cannot detect user timezone using php, but javascript can do this for you. You can also use combination of both where javascript will pass locale information to server.

0
 

Accepted Solution

by:
DelphiMan7 earned 0 total points
ID: 22869508
I managed to do it using HTTP_ACCEPT_LANGUAGE parsing the 2 letter ISO country code.  

Thanks for the suggestions anyway.  
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question