Reputation: 5727
I have a datagrid in WPF. In this datagrid, i display several bound DateTime. The dateTime are displayed in US format, and i'm French, so, i would like to display it in EU format (dd/mm/yyyy).
Is there a way to directly set the DateTime format in EU whithout parsing it to a string ? I would like to use the DateTime directly, not the string.
Thanks a lot :)
Upvotes: 0
Views: 270
Reputation: 48154
Yes. You can change the CultureInfo
or you can make a custom formatting string info here (http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx)
// a global var
string dtFormat = "mm/dd/yyyy";
//where I'm displaying my DT
Console.WrtieLine(myDT.ToString(dtFormat));
Info on CultureInfo
which is what you'll want to use if you want to do any non numerical representations. http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.datetimeformat(v=vs.71).aspx
There are also several easy to find SO questions with specific examples using CultureInfo
such as this Datetime string formatting and CultureInfo which shows how to display the three letter representation for a day in French.
Upvotes: 1