| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

DateTime

Page history last edited by Corey Alix 14 years, 10 months ago

Localization of Date Time

The DateTime ToString() method serializes a date using the current locale.  The "u" format string uses a universal pattern displaying the date from most general to most specific.  The "o" format string includes time zone information binding the time to a specific zone. 

 

Example Code

        ' create an invariant date string

        Dim lvDate1 = New DateTime(Now.Year, 6, 13, 13, 1, 1, DateTimeKind.Local)

        Dim lvDateStr1 = lvDate1.ToString("u") ' 2009-06-13 13:01:01Z

        Dim lvDateStr2 = lvDate1.ToString("o") ' 2009-06-13T13:01:01.0000000-04:00

        Dim lvDate3 = DateTime.ParseExact(lvDateStr1, "u", Globalization.CultureInfo.InvariantCulture)

        Dim lvDate4 = DateTime.ParseExact(lvDateStr2, "o", Globalization.CultureInfo.InvariantCulture)

 

References

DateTime Format Strings - http://msdn.microsoft.com/en-us/library/97x6twsz.aspx

DateTimeFormatInfo - http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo_properties.aspx

Comments (0)

You don't have permission to comment on this page.