Solved

Locale specific date formatting PHP 5.2 / MSSQL 2005 / IIS

Posted on 2010-11-26
8
725 Views
Last Modified: 2012-05-10
Hello,

   i have a web application that contains localized content.  Currently, the dates are all stored as datetime objects in an mssql 2005 database.  I am on an IIS 6 server running PHP 5.2.12 .  I am determining which content to serve up based on a language code parameter, but currently i am having some trouble with php using setlocale() in order to return a localized date ( proper language/format )   I believe this may be due to the bug described here, as I am experiencing similiar results: http://php.net/manual/en/function.setlocale.php ( warning is about 1/2 way down the page about IIS/PHP and setlocale() ) .

  I was curious if anyone had any suggestions on how best to format this date in order to display it properly to the user on the front end of the site.  Is it possible to handle this on the database level with casting in the query?

Thanks!
0
Comment
Question by:theblanc0
[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
  • 2
8 Comments
 
LVL 15

Expert Comment

by:pcsmitpra
ID: 34217174
Hi

Could you please paste error you are getting here?

Thank you.
0
 

Author Comment

by:theblanc0
ID: 34232578
I am definitely looking to perform the locale based formatting at the database level. There is not really an error in PHP, just inconsistent locale formatting being returned.  

I am running IIS.  From the PHP manual for setlocale() - :

The locale information is maintained per process, not per thread. If you are running PHP on a multithreaded server API like IIS or Apache on Windows, you may experience sudden changes in locale settings while a script is running, though the script itself never called setlocale(). This happens due to other scripts running in different threads of the same process at the same time, changing the process-wide locale using setlocale().
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 34243688
I think set_locale() is different from date_default_timezone_set(), which was required as of PHP 5.1.  Please see the article here and post back if it does not help answer your questions.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html

Best regards, ~Ray
0
 

Author Closing Comment

by:theblanc0
ID: 34387256
Thanks, that article got me where i needed to be!
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 34388129
Thanks for the points; it's a great question, ~Ray
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

Suggested Solutions

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

738 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