Skip to content

Instantly share code, notes, and snippets.

@SajjadArifGul
Created October 9, 2015 13:54
Show Gist options
  • Save SajjadArifGul/094f96004489bb8e1076 to your computer and use it in GitHub Desktop.
Save SajjadArifGul/094f96004489bb8e1076 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DateTimeFormatsInCSharp
{
class Program
{
static void Main(string[] args)
{
DateTime dt = DateTime.Now;
Console.WriteLine("Default Date Time : "+dt.ToString());
Console.WriteLine("\nDisplays the current date of the month. : " + dt.ToString("d"));
Console.WriteLine("\nDisplays only the current date of the month : " + dt.ToString("dd"));
Console.WriteLine("\nDisplays the three-letter abbreviation of the day of the week. : " + dt.ToString("ddd"));
Console.WriteLine("\nDisplays the full name of the day of the week : " + dt.ToString("dddd"));
Console.WriteLine("\nDisplays the x most significant digits of the seconds value. : " + dt.ToString("f(+)"));
Console.WriteLine("\nDisplays the era. : " + dt.ToString("g+"));
Console.WriteLine("\nDisplays the minute : " + dt.ToString("m+"));
Console.WriteLine("\nDisplays the minute where values < 10 have a zero. : " + dt.ToString("mm"));
Console.WriteLine("\nDisplays the month : " + dt.ToString("M+"));
Console.WriteLine("\nDisplays the month where values < 10 have a zero : " + dt.ToString("MM"));
Console.WriteLine("\nDisplays the three-character abbreviated name of the month. : " + dt.ToString("MMM"));
Console.WriteLine("\nDisplays the full name of the month. : " + dt.ToString("MMMM"));
Console.WriteLine("\nDisplays the number of seconds : " + dt.ToString("s+"));
Console.WriteLine("\nDisplays the first character of the AM/PM : " + dt.ToString("t+"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment