Created
October 9, 2015 13:54
-
-
Save SajjadArifGul/094f96004489bb8e1076 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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