Possible Duplicates:
Convert a string to a date in .net
format date in c#
What markup is used to format StackOverflow questions?
How to convert DateTime object to dd/mm/yyyy in C#?
Possible Duplicates:
Convert a string to a date in .net
format date in c#
What markup is used to format StackOverflow questions?
How to convert DateTime object to dd/mm/yyyy in C#?
One thing to note in addition to the other answers - / is a format character itself, representing the local date separator. If you want to make absolutely sure it uses an actual slash, either use the invariant culture (which uses a slash):
string s = dateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
or escape the slashes:
string s = dateTime.ToString("dd'/'MM'/'yyyy");
Are you talking about converting to a string for printing or something?
String s = DateTime.ToString("dd/MM/yyyy");
And to be complete, here is more information about DateTime.ToString and DateTime formatting in general.
DateTime d = DateTime.Now;
string s = d.ToString("dd/MM/yyyy");
Console.WriteLine(s);