Examples of Date Time Formatting in C#

Sajjad Arif Gul - August 1, 2016 - 1 comment

I’ve come across this best feature of C# (C sharp). If you need to specify Date Time in any custom format as your need then this feature will help you a lot.

Formatting DateTime in C#

Showing Date Time on user interface is sometimes so much important. There are also other scenarios where showing Date Time in a specified format is essential. The default date time setter i.e (DateTime.Now())’s format is not so user friendly sometimes. For this C#’s DateTime class gives some features. Below is a console application code that will show you how to get system’s date time in your own specific format.

Source Code:


Here is the output of above code.

Now you can change the date time format with your own specific needs.
Author avatar

Sajjad Arif Gul

Hi! I am Sajjad Arif Gul, Software Engineer, Web & Mobile Developer from Karachi Pakistan. I love sharing my knowledge that could possibly help someone’s life in some capacity. Happy Coding.

Related posts

1 comment

  1. Sadia Khan

    Date time formats are good in C# but handling them in different scenario are different. Im working on a project that is based on different time zones & basically tells you what time is in other corner of world. This will certainly be helpful in doing it.

Post a Comment

Your email address will not be published. Required fields are marked *