Geeks With Blogs

News



Microsoft Store

Support This Site


AddThis Social Bookmark Button

Locations of visitors to this page

Subscribers to this feed

TwitterCounter for @sdorman

Creative Commons License


Scott Dorman Microsoft MVP, Software Architect, Developer, Author

I was recently asked by a co-worker what the format string was for formatting a DateTime object in an ISO 8601 format. The way to do this is passing a format string to the ToString() method on the DateTime object. The question becomes, what is that format string? There are two ways to do this:

DateTime.Now.ToString(“yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK”)
DateTime.Now.ToString(“o”)

At this point, you might ask how you would know to use the “o”. This information is available through MSDN, but it isn’t always easy to find if you don’t already know where to look. Here is a quick “cheat sheet” of links to help you find the right information:

Posted on Friday, July 11, 2008 2:57 PM .NET (General) | Back to top

Copyright © Scott Dorman | Powered by: GeeksWithBlogs.net