🔥 Apps, books, system as a service, podcast and more



Formatting date and time using C#

formatting_date

Hi, my name is Mauricio Junior, and today I will show you many options that you can see the format dates using the C# language. I've been working in many companies around the World, Europe, North and South America, and it is very important to format the date based on the country.

You can see more about my course on plataforma.academy and there I can teach you more about the language C# https://plataforma.academy/cursos/category/10/programacao and many other languages.

The format date and time can be used on mobile, desktop, api, console, and web application without any issue.

Format

DateTime.Now.ToString("MM/dd/yyyy") => 05/29/2025

DateTime.Now.ToString("dddd, dd MMMM yyyy") => Friday, 29 May 2025

DateTime.Now.ToString("dddd, dd MMMM yyyy") => Friday, 29 May 2025 05:50

DateTime.Now.ToString("dddd, dd MMMM yyyy") => Friday, 29 May 2025 05:50 AM

DateTime.Now.ToString("dddd, dd MMMM yyyy") => Friday, 29 May 2025 5:50

DateTime.Now.ToString("dddd, dd MMMM yyyy") => Friday, 29 May 2025 5:50 AM

DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss") => Friday, 29 May 2025 05:50:06

DateTime.Now.ToString("MM/dd/yyyy HH:mm") => 05/29/2025 05:50

DateTime.Now.ToString("MM/dd/yyyy hh:mm tt") => 05/29/2025 05:50 AM

DateTime.Now.ToString("MM/dd/yyyy H:mm") => 05/29/2025 5:50

DateTime.Now.ToString("MM/dd/yyyy h:mm tt") => 05/29/2025 5:50 AM

DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") => 05/29/2025 05:50:06

DateTime.Now.ToString("MMMM dd") => May 29

DateTime.Now.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss.fffffffK") => 2025-05-16T05:50:06.7199222-04:00

DateTime.Now.ToString("ddd, dd MMM yyy HH’:’mm’:’ss ‘GMT’") => Fri, 16 May 2025 05:50:06 GMT

DateTime.Now.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss") => 2025-05-16T05:50:06

DateTime.Now.ToString("HH:mm") => 05:50

DateTime.Now.ToString("hh:mm tt") => 05:50 AM

DateTime.Now.ToString("HH:mm:ss")	 => 05:50:06

DateTime.Now.ToString("yyyy MMMM") => 2025 May

DateTime.Now.ToString("dd MMMM yyyy") => 29 May 2025

I hope you liked it and it can help you, like it helped me. Sometimes it is very util to see or remember the different formats possible using C# and comparing to other languages, C# makes the easy to do it.

image

https://plataforma.academy/curso/25/charp-basico

Sign up to our newsletter

Receive our latest updates about programming languages, software, database, books, ebooks, classes, jobs and more.

Top