Wednesday, April 11, 2012

Change System Datetime Format programmatically


         //Set Dateformat for the system
            string strCurCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
            System.Globalization.CultureInfo culNew = new System.Globalization.CultureInfo(strCurCulture);
            culNew.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
            culNew.DateTimeFormat.DateSeparator = "/";

            System.Threading.Thread.CurrentThread.CurrentCulture = culNew;
            System.Threading.Thread.CurrentThread.CurrentUICulture = culNew;