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,573 other followers

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.

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

  1. […] the past I wrote about a Simple example to show DateTime.Now in ISO 8601 format on ideone.com | Online C# Compiler & Debu…, using ISO 8601 in batch-files, and how ISO 8601 is used in Google Calendar […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: