Solved

Locale specific date formatting PHP 5.2 / MSSQL 2005 / IIS

Posted on 2010-11-26
8
722 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
  • 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 109

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 109

Expert Comment

by:Ray Paseur
ID: 34388129
Thanks for the points; it's a great question, ~Ray
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 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