Skip to main content
added some text
Source Link
Shaiju T
  • 6.7k
  • 24
  • 112
  • 201

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 AM Date Only : 04/09/2016 

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

For More Date and Time formatingformatting check these links:

Reference 1

Reference 2

Hope helps.

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 AM Date Only : 04/09/2016 

This also works if the date is stored in database.

More Date and Time formating check these links:

Reference 1

Reference 2

Hope helps.

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 AM Date 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.

Source Link
Shaiju T
  • 6.7k
  • 24
  • 112
  • 201

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 AM Date Only : 04/09/2016 

This also works if the date is stored in database.

More Date and Time formating check these links:

Reference 1

Reference 2

Hope helps.