get user language date format in current culture

Viewed 40

By date format I don't mean the one used by .net to format date types

Date format shown to the user with a french culture could be jj/mm/aaaa (jour = day, mois = month, an = year). For example in html an <input type="date" /> would show the format above as an input placeholder.

does .net have this format info available ?

1 Answers

When you specify the culture (replace en-US with your culture:

CultureInfo.GetCultureInfoByIetfLanguageTag("en-US").DateTimeFormat.ShortDatePattern;

Or with the Current Culture

CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;

RESULTS The first will return M/d/yyyy The second will return (in my case, as I am in Switzerland) dd/MM/yyyy

Related