.NET Time Zone Information

What is the standard format for datetime with timezone in an ASP.NET ASP.NET application?

Updated to clarify: in ASP.NET, I need to check the datetime from a Domino database with a .NET DateTime. The client asks what will be the best format in which he must provide the date and time with the time zone. So which format is the most readable .NET?

+3
source share
3 answers

Update - regarding your clarification:

datetime dominos asp.net datetime. , , . - .Net.

.NET , , . , , ParseExact TryParseExact.

:

- , ISO 8601, : 2010-05-14T10:04Z. DateTime.Parse , .


:

DateTime ASP.NET ASP.NET?

DateTimes . , CultureInfo.InvariantCulture, .

DateTime now = DateTime.Now;
string s = now.ToString(CultureInfo.InvariantCulture);

:

"05/14/2010 21:17:35"

, . :

string s = now.ToString("yyyy-MM-dd HH:mm:ss zz");

:

"2010-05-14 21:21:59 +02"
+2

:

MM/DD/YYYY HH:MM:SS (AM/PM)

CultureInfo, . MSDN:

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

0

Assuming you meant a string from a DateTime object, the easiest way would be to use DateTime.Parse("MM/DD/YY HH:mm:ss UTC-OFFSET"), for example, "03/01/2009 05:42:00 -5: 00". For more information, see the Parse documentation .

0
source

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


All Articles