0

I have a winforms application written in C#, I need to know how to change local system's date format from my application.

Will it require the application to run under administrator's permission ?

assylias
  • 321,522
  • 82
  • 660
  • 783
Mando
  • 3
  • 4
  • If you need to use a specific date format using actual local system date you may have a look at this doc from Microsoft : https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings. No need of administrator privilege for that. – Guillaume Raymond Mar 20 '18 at 13:51
  • @Mando Can you accept the answer if it helped you... – Milana Apr 03 '18 at 10:44

1 Answers1

0

You need to change the date format in the registry:

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true);

key.SetValue("sShortDate", "d/M/yy");
key.SetValue("sLongDate", "dd/MM/yy");

It might take a few seconds until you see it changed.

If you're only changing the registry for the current user you don't need admin privileges (source)

Milana
  • 557
  • 9
  • 20