Monday, 1 October 2012

SET DATE TIME FORMAT IN C#


using System;

class Program
{
    static void Main()
    {
 DateTime time = DateTime.Now;              // Use current time
 string format = "MMM ddd d HH:mm yyyy";    // Use this format
 Console.WriteLine(time.ToString(format));  // Write to console
    }
}

MMM display three-letter month ddd display three-letter day of the WEEK d display day of the MONTH HH display two-digit hours on 24-hour scale mm display two-digit minutes yyyy display four-digit year



 System.DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss")
Refrence: http://www.dotnetperls.com/datetime-format

No comments:

Post a Comment