date format converter?
-
Hi there i an a newbie to c# how can i change the date to british date format?(dd-mm-yy) in my applications? VisionTec
Here is an example:
MessageBox.Show(DateTime.Now.ToString("dd-MM-yy"));
-
Hi there i an a newbie to c# how can i change the date to british date format?(dd-mm-yy) in my applications? VisionTec
A better way is to use an
IFormatProvider
for the BritishCultureInfo
. For example,String.Format
can take anIFormatProvider
as the first parameter. This could be theCultureInfo.NumberFormat
for theCultureInfo
for the English (Britain) culture. By default, such methods uses theThread.CurrentCulture
but as I've mentioned you can override this behavior by passing anIFormatProvider
. This is the correct way, instead of assuming and managing custom format specifiers like the previous post mentioned. For more information about localization and culture-specific formatting, see Developing World-Read Applications[^] in the .NET Framework SDK. With regard to your question, see Formatting Date and Time for a Specific Culture[^] under the previous topic.Microsoft MVP, Visual C# My Articles