Solved

Locale specific date formatting PHP 5.2 / MSSQL 2005 / IIS

Posted on 2010-11-26
8
717 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 108

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 108

Expert Comment

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
The viewer will learn how to count occurrences of each item in an array.

707 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now