DateTime.ToString(“MM/dd/yyyy HH:mm:ss.fff”) resulted in something like “09/14/2013 07.20.31.371”

后端 未结 6 1963
旧巷少年郎
旧巷少年郎 2020-12-22 20:08

I have a WP8 app, which will send the current time to a web service.

I get the datetime string by calling

DateTime.ToString(\"MM/dd/yyyy HH:mm:ss.ff         


        
6条回答
  •  借酒劲吻你
    2020-12-22 20:52

    I bumped into this problem lately with Windows 10 from another direction, and found the answer from @JonSkeet very helpful in solving my problem.

    I also did som further research with a test form and found that when the the current culture was set to "no" or "nb-NO" at runtime (Thread.CurrentThread.CurrentCulture = new CultureInfo("no");), the ToString("yyyy-MM-dd HH:mm:ss") call responded differently in Windows 7 and Windows 10. It returned what I expected in Windows 7 and HH.mm.ss in Windows 10!

    I think this is a bit scary! Since I believed that a culture was a culture in any Windows version at least.

提交回复
热议问题