0

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.?

Avinash patil
  • 1,689
  • 4
  • 17
  • 39
user3475314
  • 75
  • 1
  • 3
  • 7

2 Answers2

3

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.
Lineesh
  • 106
  • 1
  • 1
  • 6
1

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);
citronas
  • 19,035
  • 27
  • 96
  • 164