The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,465 other followers

Archive for May 17th, 2011

Simple example to show DateTime.Now in ISO 8601 format on ideone.com | Online C# Compiler & Debugging Tool

Posted by jpluimers on 2011/05/17

I’m a fan of ISO 8601, as it is a universal way of expressing dates and times (no more MDY confusion ).

I wrote about using ISO 8601 in batch-files and with Google Calendar before.

Now it is time to give you a simple C# example.

When you realize that XML uses ISO 8601 for their date and time formats, the .NET conversion is very easy:

using System;
using System.Xml;

public class Test
{
    public static void Main()
    {
        string Iso8601DateTime =
            XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Local);
        Console.WriteLine(Iso8601DateTime);
    }
}

I wrote about ideone.com before: it is an excellent place to run sample C# code (and other languages).

When running this on ideone.com, you can see their local server time in ISO 8601 format.
Cute :-)

BTW: There are more ways to run your C# code online.

–jeroen

via: Simple example to show DateTime.Now in ISO 8601 format on Ideone.com | Online C# Compiler & Debugging Tool.

Posted in .NET, C#, Development, ISO 8601, Power User, Software Development | 1 Comment »

 
%d bloggers like this: