Solved

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

Posted on 2008-10-26
2
934 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

Independent Software Vendors: 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

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.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

623 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