Note that there are some explanatory texts on larger screens.

plurals
  1. POChange System DateTime Format c#
    text
    copied!<p>I need to change/update/set my system (windows7) default dateTime format <strong>programatically</strong> and permanently until I change it myself through code or through windows GUI</p> <p>I have tried a lot of solutions like this one from <a href="http://www.codeproject.com/Questions/168386/How-to-change-system-date-format-c" rel="nofollow noreferrer">Code Project</a></p> <pre><code> Console.Write(DateTime.Now + ""); RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@" Control Panel\International", true); rkey.SetValue("sShortDate", "dd/MM/yyyy"); rkey.SetValue("sLongDate", "dd/MM/yyyy"); Console.Write(DateTime.Now + ""); </code></pre> <p>The closest and well reputed answer is following from from <a href="https://stackoverflow.com/questions/1389187/set-default-datetime-format-c-sharp">Set Default DateTime Format c#</a>, I tried this solution but it did not help me. As It does not change my system datetime format (shown in taskbar). And after I restart the app having this code, I again get the old format before this code is executed.</p> <pre><code>using System; using System.Globalization; using System.Threading; namespace test { public static class Program { public static void Main() { Console.Write(DateTime.Now + "");// MessageBox.Show(DateTime.Now + ""); CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); culture.DateTimeFormat.ShortDatePattern = "dd-MMM-yyyy"; culture.DateTimeFormat.LongTimePattern = ""; Thread.CurrentThread.CurrentCulture = culture; Console.Write(DateTime.Now + "");// MessageBox.Show(DateTime.Now + ""); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload