Date Conversion Problem
i have Converted by code Date Formate DD/MM/YYYY Locally but when Publish Application on Windows Server 2008 then Automatically display date in MM/DD/开发者_JS百科yyyy any body tell me what is Problem.. so Windows server 2008 display date in DD/MM/YYYY Code is as Under which is not working
System.IFormatProvider frmt = default(System.IFormatProvider);
frmt = new System.Globalization.CultureInfo("en-US", true);
dtDate1 = Convert.ToDateTime(txtFromDate.Text, frmt);
Date conversion (from string) using DateTime.Parse() has the nasty habbit of using the locale settings for the computer it is running.
A better way of converting is to run DateTime.TryParseExact() and explicitly supply your expected date formats.
Your regional setting on server are probably different from your workstation; you could use DateTime.ParseExact
to make your application culture safe
Make sure that the regional settings on the server are correct, and/or use an explicit format in the application if you want the date format to remain the same regardless of regional settings.
精彩评论