Wednesday, 7 August 2013

How to read computer's datetime format and change the code appropriately

How to read computer's datetime format and change the code appropriately

I have some code that subtracts user specified number of days from a
todays date and writes something out. We used dd-mm-yyyy format. During
testing, on machines that have mm-dd-yyyy format it subtacted months
instead of days. Looks like this:
DateTime Date1 = DateTime.Now.Subtract(new TimeSpan(days, 0, 0, 0));
How can we read the computer's datetime format, and modify the subtract if
the format is different than ours.
Thanks.

No comments:

Post a Comment