9. Time and Date : Get system time and convert it in different formats 'DD-MON-YYYY', 'mm-dd-yyyy', 'dd/mm/yy' etc.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace lrn2csharp9
{
class Program
{
static void Main( string[ ] args )
{
DateTime now = DateTime.Now;
Console.WriteLine( "Today's date is: " + now.ToString( "MMM dd yyyy HH:mm:ss" ) );
Console.WriteLine( "Also: " + now.ToString( "dd-MMM-yyyy" ) );
Console.WriteLine( "And: " + now.ToString( "MM-d-yyyy" ) );
Console.WriteLine( "One more thing: " + now.ToString( "d/MM/yy" ) );
}
}
}
posted by dharh 3:03 PM Sep 30th, 2010