I want to set user date format yyyyMMdd using culture name. Which culture name have to specify to accomplish this?
+4
A:
Why wouldn't you use the format specifier?
string s = DateTime.Today.ToString("yyyyMMdd");
I'm not aware of any pre-rolled cultures that use this specifier. You could perhaps roll your own culture?
Marc Gravell
2009-05-18 07:10:50
If I set the culture name, don't need to handle MaskedEditExtender and CalendarExtender and no other handling required
Muhammad Akhtar
2009-05-18 07:13:35
I don't know of a way to do it just using the culture...
Marc Gravell
2009-05-18 07:17:49
@Muhammad: by setting the culture you will also affect other things, such as numeric formats (thousand separator, decimal character), currency symbols and such.
Fredrik Mörk
2009-05-18 07:19:22
yes, you are right, but this time I need only date format.
Muhammad Akhtar
2009-05-18 07:54:19
the issue here is , MaskedEditExtender only validate when we set culture property, rather only set date format.
Muhammad Akhtar
2009-05-18 07:59:24
+4
A:
You can create your own culture using the CultureAndRegionInfoBuilder class (in assembly sysglobl). But it may be overkill for your need...
Another, simpler solution : create a new instance of CultureInfo based on the current culture, and assign it a custom DateTimeFormatInfo :
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
dtfi.ShortDateTimePattern = "yyyyMMdd";
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name);
ci.DateTimeFormat = dtfi;
Thomas Levesque
2009-05-18 08:35:04
+1
A:
This link might help you in understanding number and DateTime formatting as well as culture specific formatting overriding. It basically demonstrates it by remodifying the msdn code examples:
YordanGeorgiev
2009-05-20 09:35:23