public static void Main(string[] args)
{
//Get the cureent date time
DateTime datetTime= DateTime.Now;
Formatting DateTime to full pattern (dddd, MMMM dd, yyyy hh:mm:ss)
Console.WriteLine(dt.ToString("F"));
Formatting DateTime to short date- time pattern (dddd, MMMM dd, yyyy, hh:mm)
Console.WriteLine(dt.ToString("f"));
Formatting DateTime to short date numerical pattern (M/d/yyyy)
Console.WriteLine(dt.ToString("d"));
Formatting DateTime to full date numeric pattern (dddd, MMMM dd, yyyy)
Console.WriteLine(dt.ToString("D"));
To the short date&time numerical pattern (M/d/yyyy hh:mm)
Console.WriteLine(dt.ToString("g"));
To the full date&time numerical pattern (M/d/yyyy hh:mm:ss)
Console.WriteLine(dt.ToString("G"));
DateTime to the month name pattern (MMMM dd)
Console.WriteLine(dt.ToString("m"));
DateTime to the short date pattern (MMMM, yyyy)
Console.WriteLine(dt.ToString("y"));
DateTime to the long time pattern (hh:mm:ss)
Console.WriteLine(dt.ToString("T"));
DateTime to the short time pattern (hh:mm)
Console.WriteLine(dt.ToString("t"));
DateTime to the RFC1123 pattern (ddd, dd MMM yyyy HH':'mm':'ss 'GMT')
Console.WriteLine(dt.ToString("r"));
DateTime to sortable pattern This format is based on ISO 8601 and uses local time.
Console.WriteLine(dt.ToString("s"));
DateTime to full date&time using universal time
Console.WriteLine(dt.ToString("U"));
DateTime to universal sortable pattern (yyyy'-'MM'-'dd HH':'mm':'ss'Z')
Console.WriteLine(dt.ToString("u"));
}
0 comments:
Post a Comment