Date format differs on Local Machine as well as Production Machine or Error : String was not recognized as a valid DateTime

Technology: ASP.Net 4.5

DateTime format conversions are a nightmare for the developers as I see.

But to convert a datetime in .Net is super easy!. All you have to do is go to your Web.Config file and add the following Globalization tag into it, with the intended UI Culture.

UI Culture for UK

<system.web>
 <globalization 
 requestEncoding="utf-8" 
 responseEncoding="utf-8" 
 culture="en-GB" 
 uiCulture="en-GB" />
 </system.web>

UI Culture for US

<system.web>
 <globalization 
 requestEncoding="utf-8" 
 responseEncoding="utf-8" 
 culture="en-US" 
 uiCulture="en-US" />
 </system.web>

Cheers!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s