Quantcast
Channel: How to remove time portion of date in C# in DateTime object only? - Stack Overflow
Viewing all articles
Browse latest Browse all 42

Answer by Shaiju T for How to remove time portion of date in C# in DateTime object only?

$
0
0

Here is another method using String.Format

    DateTime todaysDate = DateTime.UtcNow;    string dateString = String.Format("{0:dd/MM/yyyy}", todaysDate);    Console.WriteLine("Date with Time: "+ todaysDate.ToString());    Console.WriteLine("Date Only : "+ dateString);

Output:

Date with Time: 9/4/2016 11:42:16 AMDate Only : 04/09/2016

This also works if the Date Time is stored in database.

For More Date and Time formatting check these links:

Reference 1

Reference 2

Hope helps.


Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>