Accurately analyzes the date and time string of the international time zone
When dealing with the date stamp of information containing international time zones, it is important to accurately analyze to retain the expected time zone interpretation. This article focuses on how to analyze the date string of "DD-MMM-YY HH: MM: SS CEST".
.NET framework provides a custom date and time format string to meet the needs of various formats. However, the document does not clearly provide format description symbols used to analyze PST/CEST/UTC and other forms.
Alternative analysis method
Because there is no built -in time zone abbreviation format description symbol, a alternative method is to replace the abbreviation with the corresponding time zone offset. For example:
Here, 2 indicates the UTC displacement of CEST.Extension format options
<code>DateTime dt1 = DateTime.ParseExact( "24-okt-08 21:09:06 CEST".Replace("CEST", "+2"), "dd-MMM-yy HH:mm:ss z", culture);</code>
In order to more accurate analysis, you can use the expansion format description symbols, such as ZZ and ZZZ:
By replacing the time zone abbreviation with offset, you can successfully analyze the international date string and accurately explain the expected time zone.
The above is the detailed content of How to Parse Date and Time Strings with International Time Zone Abbreviations in .NET?. For more information, please follow other related articles on the PHP Chinese website!