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






ISO 8601 Date, Time and DateTime in Delphi (was: Simple example to show DateTime.Now in ISO 8601 format on ideone.com | Online C# Compiler & Debugging Tool) « The Wiert Corner – irregular stream of Wiert stuff said
[…] 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 […]