I am looking for a solution to get system date time format.
For example: if I get DateTime.Now
? Which Date Time Format is this using? DD/MM/YYYY>
The answers above are not fully correct.
I had a situation that my Main thread and my UI thread were forced to be in "en-US" culture (by design). My Windows DateTime format was "dd/MM/yyyy"
string sysFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
string sysUIFormat = CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern;
returned "MM/dd/yyyy", but I wanted to get my real Windows format. The only way I was able to do so is by creating a dummy thread.
System.Threading.Thread threadForCulture = new System.Threading.Thread(delegate(){} );
string format = threadForCulture.CurrentCulture.DateTimeFormat.ShortDatePattern;