Setting the yyyyMMdd date format by defining the culture name
3 answers
You can create your own culture using the CultureAndRegionInfoBuilder class (in the sysglobl assembly). But that might be overkill for your need ...
Another, simpler solution: create a new CultureInfo instance based on the current culture and assign it to a custom DateTimeFormatInfo:
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.ShortDateTimePattern = "yyyyMMdd";
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name);
ci.DateTimeFormat = dtfi;
+6
a source to share