How to convert date format to DD-MM-YYYY in C#

saurav2109 picture saurav2109 · Jan 10, 2011 · Viewed 265.6k times · Source

How to convert date format to DD-MM-YYYY in C#? I am only looking for DD-MM-YYYY format not anything else.

Answer

alexn picture alexn · Jan 10, 2011
string formatted = date.ToString("dd-MM-yyyy");

will do it.

Here is a good reference for different formats.