ASP MVC DateTime Problem Model Validation Problem

I have MS SQL on the local development server and on the production server. My local server's DateTime format is "mm / dd / yyyy", but the format on the production server is "dd / mm / yyyy". Everything worked fine on my local server, but when I try to enter a date, for example, "05/31/2010" on my production server, the Validation model generated an error "The value" 05/31/2010 "is invalid for ....", so as a month it cannot be more than 12. I do not want to change the DateTime on any of the servers. Can some body tell me how to get rid of this problem so that everything works fine on both of my servers?

+3
source share
2 answers

You can try adding the Globalization element to web.config - Configuration> System.web:

<globalization culture="en-US" uiCulture="en-US" />

I had a similar problem - although, admittedly, as a Briton, on the contrary, and this fixed the problem.

+1
source

I think this article is probably you after, in terms of how model binding works with localization.

, , , , . , - , , , .

, , - - , , - DateTime DateTimeOffset .

0

Source: https://habr.com/ru/post/1764365/


All Articles