|
Formatting Dates by Culture
Published: 10/20/2008 |
|
I was answering questions over on VBCity the other day and came across a post asking how to format dates for different cultures without changing the current culture of the application. The ToString override of the DateTime object accepts a parameter that lets you specify the culture that the date should be formatted for. Here's the code:
VB:
Dim clsCulture As New System.Globalization.CultureInfo("ar-EG")
Dim sDate As String = DateTime.Now.ToString("D", clsCulture)
System.Diagnostics.Debug.WriteLine(sDate)
System.Globalization.CultureInfo clsCulture
= new System.Globalization.CultureInfo("ar-EG");
string sDate = DateTime.Now.ToString("D", clsCulture);
System.Diagnostics.Debug.WriteLine(sDate);
Questions or Comments? .
VB to C# and C# to VB translation provided by Instant C# and Instant VB.