user613326 user613326 - 1 year ago 111
C# Question

changing the system time format on windows 7

Well I am looking for a method to change the default windows 7 time format for a system.
So if a system uses like 10PM or 10 AM as default time notation, then i like to change that system to 10:00 or 22:00.

I know how to do it through the GUI, but in my case our software (C#) has to check if time notation is OK and if it is not change it by usage of
C#, registry editing, vbscript, commanline or Powershell, or some specific .exe file
The software we wrote allready makes usage of external progs / languages (vbscript/powershell).
But the problem is so far i have not found a method to do this other then taking over a remote screen.

Perhaps someone knows how to do this ?
The same counts for time zone, and date notation.

Answer Source

You may change the system time format using following code:

RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Control Panel\International", true);
rk.SetValue("sTimeFormat", "hh:mm:ss"); // HH for 24hrs, hh for 12 hrs

But IMO, this would not be a good practice for an application to change the system user's settings without the consent of the user.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download