Standard and Custom Format Strings

  • 1 minute to read
  • edit

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:


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: