You may sometimes need to change your system Date format at run time. C# has namespace ‘
’ which helps you to change your system date and currency format.
Using the Code
First, you just have to use namespace
RegistryKey class to access Current user preferences. Then you can set value for date format using
Use this to specify the numeric value for the day of the month.
Eg. d (1) or dd(01) or ddd(MON) or dddd(MONDAY).
These display the months in numeric form.
Eg. M(1) or MM(01) or MMM(JAN) or MMMM(JANUARY).
Use this to specify the numeric value for the year to different digits.
Eg. y(9) or yy(09) or yyyy(2009).
Apart from these, you may also use follow:
Points of Interest
This is very easy code to change system date format at runtime. Following are the class methods with their uses.
You can use this code to change system currency format too.
15 March 2011: Initial release