Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Locale specific date formatting PHP 5.2 / MSSQL 2005 / IIS

Posted on 2010-11-26
8
Medium Priority
?
728 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 111

Accepted Solution

by:
Ray Paseur earned 2000 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 111

Expert Comment

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

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

721 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