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?
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
Hi you can use CultureInfo
You'll need to import Globalization
using System.Globalization;
If you need more explanation, click here
Here's a code example:
DateTime thisDate = new DateTime(2022,08,13);
CultureInfo culture = new CultureInfo("fr-FR");
Console.WriteLine(thisDate.ToString("d", culture));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.