Solved

Locale specific date formatting PHP 5.2 / MSSQL 2005 / IIS

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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

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.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

626 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