Date Formatting C# with Example
DateTime date = new DateTime(2016, 07, 06, 18, 30, 14); // Format: year, month, day hours, minutes, seconds Console.Write(String.Format("{0:dd}",date)); //Format by Culture info String.Format(new System.Globalization.CultureInfo("mn-MN"),"{0:dddd}",date); Version ≥ 6.0 Console.Write($"{date:ddd}"); output : 06 Л х аг ва 06 Specifier Meaning Sample Result {0:d} d Date 7/6/2016 dd Day, zero-padded {0:dd} 06 ddd Short day name {0:ddd} Wed dddd Full day name {0:dddd} Wednesday {0:D} D Long date Wednesday, July 6, 2016 f Full date and time, short {0:f} Wednesday, July 6, 2016 6:30 PM ff Second fractions, 2 digits {0:ff} 20 fff Second fractions, 3 digits {0:fff} 201 {0:ffff} ffff Second fractions, 4 digits 2016 F Full date and time, long {0:F} Wednesday, July 6, 2016 6:30:14 PM {0:g} g Default date and time 7/6/2016 6:30 PM {0:gg} gg Era A.D hh Hour (2 digits, 12H) {0:hh} 06 HH Hour (2 digits, 24H) {0:HH} 18 {0:M} M Month and day July 6 {0:mm} mm Minutes, zero-padded 30 MM Month, zero-padded {0:MM} 07 MMM 3-letter month name {0:MMM} Jul {0:MMMM} MMMM Full month name July {0:ss} ss Seconds 14 r RFC1123 date {0:r} Wed, 06 Jul 2016 18:30:14 GMT s Sortable date string {0:s} 2016-07-06T18:30:14 {0:t} t Short time 6:30 PM T Long time {0:T} 6:30:14 PM tt AM/PM {0:tt} PM u Universal sortable local time {0:u} 2016-07-06 18:30:14Z {0:U} U Universal GMT Wednesday, July 6, 2016 9:30:14 AM Y Month and year {0:Y} July 2016 yy 2 digit year {0:yy} 16 yyyy 4 digit year {0:yyyy} 2016 zz 2 digit timezone offset {0:zz} +09 {0:zzz} zzz full time zone offset +09:00