Why might my local machine be incorrectly formatting international dates?

前端 未结 2 637
轻奢々
轻奢々 2020-12-21 22:10

Here\'s a weird one...

I\'ve just seen a (previously passing) test fail because of extra spaces in a string representation of a date. The test in question has previo

2条回答
  •  [愿得一人]
    2020-12-21 22:34

    I had the same issue in my Windows 10 machine, got "31. 1. 208". But using:

    var format = "d.M.yyyy";
    

    produces: 31.1.2018

    it seams to be something with CultureInfo("sk-SK"):

    Console.WriteLine(date.ToString("d", new CultureInfo("de-DE")));
    

    produces: 31.01.2018

    and

    Console.WriteLine(date.ToString("d/M/yyyy", new CultureInfo("de-DE")));
    

    produces: 31.1.2018

    (in Windows Control Panel - Region, mine is set as "English - Canada" and short date: "dd/MM/yyyy".

    It seems to be defined in the .Net Framework - see the spaces there:

    I hope that helps.

提交回复
热议问题