I have expanded on the suggestion by Bart Calixto to fix the dd MMM yyyy format issue (here in Australia we also use UK date format dd/mm/yy)
I also frequently need to convert between Aust and US date formats.
This code fixes the problem (my version is in VB)
Public Shared Function ToLongDateWithoutWeekDayString(source As DateTime, cult As System.Globalization.CultureInfo) As String
Return source.ToString("D", cult).Replace(source.DayOfWeek.ToString(), "").Trim(","c, " "c)
End Function
Before calling the function you need to set culture, I do it this way after getting the visitor's country from http://ipinfo.io
Select Case Country.country
Case "AU"
cult = New CultureInfo("en-AU")
Case "US"
cult = New CultureInfo("en-US")
Case "GB"
cult = New CultureInfo("en-GB")
End Select
Dim date1 As New Date(2010, 8, 18)
lblDate.Text = ToLongDateWithoutWeekDayString(date1, cult)
After setting AU or GB culture result is 18 August 2010
After setting US culture result is August 18, 2010
Adam do you agree this solves the formatting issue you refer to?
Thanks Bart that was very nice code.
Dont forget to add Dim cult As System.Globalization.CultureInfo
after
Inherits System.Web.UI.Page