The output of DateTime.ToString ("d", cultureInfo) is different from IIS and the console application

I use DateTime.Now.ToString("d", new CultureInfo("nl-NL")).

In the local IIS web application, the output is correct:

22-7-2016

In the console application, the structure selects an international / culturally-invariant date notation:

2016-07-22

This is on the same machine with the same code. I set a breakpoint, checked all the input, and even tried to run the commands in a direct window at that point. In any situation, the console application is erroneous.

Can anyone explain the reason for the difference?

+4
source share
2 answers

IIS . (, Region), CultureInfo .

CultureInfo, :

new CultureInfo("nl-NL", useUserOverride: false)

reset : Run > intl.cpl > NL > > Reset.

+3

, - .NET 4.5 VS 2012.

?

yourDateTime.ToString("dd-MM-yyyy", new System.Globalization.CultureInfo("nl-NL"));
-1

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


All Articles