0

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 ?

buga
  • 852
  • 9
  • 21
  • 1
    [`CultureInfo`](https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=net-6.0) ? – Cid Sep 12 '22 at 08:31
  • Do you need to get culture info from the HTML page to your dotnet backend in asp.net MVC application or something? – xakpc Sep 12 '22 at 08:51
  • @xakpc no, the html input type date was only an example of the kind of date format that I need – buga Sep 12 '22 at 09:00

1 Answers1

0

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

  • no, I need the format to show to the user not to format date, in german it would be perhaps something like TT.MM.JJJJ (tag, monath, jahr) – buga Sep 12 '22 at 08:41
  • 1
    True, for Germany/German it will give dd.MM.yyyy (with dots), not TT No, it seems not to be available Let me think of an easy solution – Frederik van Lierde Sep 12 '22 at 08:53