Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 254
saurav2109 Avatar asked Jan 10 '11 17:01

saurav2109


People also ask

How do I change date format to mm dd yyyy?

From mm/dd/yyyy to dd/mm/yyyy To change the date display in Excel follow these steps: Go to Format Cells > Custom Enter dd /mm /yyyy in the available space.

How do I change the format of dd mm yyyy to dd mm yyyy?

Your answer First, pick the cells that contain dates, then right-click and select Format Cells. Select Custom in the Number Tab, then type 'dd-mmm-yyyy' in the Type text box, then click okay. It will format the dates you specify.

What is the format for dd mm yyyy?

yyyy — Example: 23.06. 2013. dd/MM/yyyy — Example: 23/06/2013. yyyy/M/d — Example: 2013/6/23.

How do I change the date format from yyyy mm dd in C#?

string date = DateTime. ParseExact(SourceDate, "dd/MM/yyyy", CultureInfo. InvariantCulture). ToString("yyyy-MM-dd");


2 Answers

string formatted = date.ToString("dd-MM-yyyy"); 

will do it.

Here is a good reference for different formats.

like image 64
alexn Avatar answered Oct 19 '22 07:10

alexn


According to one of the first Google search hits: http://www.csharp-examples.net/string-format-datetime/

// Where 'dt' is the DateTime object... String.Format("{0:dd-MM-yyyy}", dt); 
like image 22
Teekin Avatar answered Oct 19 '22 08:10

Teekin