user3475314
user3475314

Reputation: 75

How to resolve Date format change Issue after deployment in asp.net?

When I'm using DateTime in dd-MM-yyyy format. When I debug my code at localhost its works fine. But After deploying my ASP.NET web project on IIS server DateTime changes to mm-dd-yyyy format automatically.I'm facing many issues because of this problem. I'm not able to find any solution, please let me know how can I solve this.

How can I get rid of this issue.?

Upvotes: 0

Views: 6238

Answers (2)

citronas
citronas

Reputation: 19365

Your IIS probably has another Localization selected, than on your development machine.

Printing should be pretty simple if you specify the format: yourDate.ToString("dd.MM.yyyy");

Parsing a date has been a problem for me in the past. You can change the server settings or specify a CultureInfo directly in the code, like this:

DateTime.ParseExact(myDateString, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None);

Upvotes: 1

Lineesh
Lineesh

Reputation: 116

1) Change the datetime format of your server from:

Control Panel -> Regional and Language Options -> Advanced

2) Open IIS and follow below steps: (For IIS7)

  • Click on you Website
  • Select .NET GLOBALIZATION option
  • From Culture tab, select required Culture and UI Culture.
  • Finally iisreset.

Upvotes: 3

Related Questions