Solved

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

Posted on 2008-10-26
2
926 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

751 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