Improving on the accepted answer, GetAllDateTimePatterns can take a parameter to restrict the result to patterns relating to a standard format string, such as 'D' for the long date pattern.
For example, GetAllDateTimePatterns('D') is currently returning this for en-US:
"dddd, MMMM d, yyyy", "MMMM d, yyyy", "dddd, d MMMM, yyyy", "d MMMM, yyyy"
and this for zh-HK:
"yyyy'年'M'月'd'日'", "yyyy'年'MM'月'dd'日'", "yyyy年MMMd日", "yyyy年MMMd日, dddd"
Assuming they're listed in some order of preference or prevalence, we can select the first option that does not contain the day of the week.
Here are extension methods so you can simply use myDateTime.ToLongDateStringWithoutDayOfWeek() and myDateTime.ToLongDateTimeStringWithoutDayOfWeek().
public static string ToLongDateStringWithoutDayOfWeek(this DateTime d)
{
return d.ToString(
CultureInfo.CurrentCulture.DateTimeFormat.GetAllDateTimePatterns('D')
.FirstOrDefault(a => !a.Contains("ddd") && !a.Contains("dddd"))
?? "D");
}
public static string ToLongDateTimeStringWithoutDayOfWeek(this DateTime d, bool includeSeconds = false)
{
char format = includeSeconds ? 'F' : 'f';
return d.ToString(
CultureInfo.CurrentCulture.DateTimeFormat.GetAllDateTimePatterns(format)
.FirstOrDefault(a => !a.Contains("ddd") && !a.Contains("dddd"))
?? format.ToString());
}