C # parse regional timestamps for date

I am trying to make a small application for a project that can be used by clients from all over the world. The problem I am facing is that the background file is being configured using XML files that are generated and uploaded to the public network, and in these XML files I store a date time variable that says when the task starts and ends. The program crashes at certain loading intervals with the exception of the format, and after some research it turned out that I needed to configure a regional time parser.

I have a question, how can I convert time to an XML file, regardless of whether it uses the US, AU or UK regional settings and whether it uses local client settings. This is done using VS C # 2005 and the .NET 3.5 environment.

Thanks in advance for your help.

+3
source share
2 answers

Backends should be recorded in a standard format. XML does not just have to use the local date format - thus madness. The highlight of XML is the exchange format for computers, not for people. Unless you format something for human consumption, you should not use local options.

, , CultureInfo.InvariantCulture , dt.ToString("o") , .

(.. , ), , , UTC . , DateTime.UtcNow DateTime.Now.

, , .

, , , , , CultureInfo DateTime.TryParseExact. , , . , , , . , 03/05/2010 5 2010 3 2010 . , .

+8

. . ( DateTime.Parse .ParseExact. .

Date?

+1

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


All Articles