I live in Canada, the DateTime.Today format is recorded as dd/mm/yyyy. It is strange when I run the application as administrator, it records the DateTime.Today format as mm/dd/yyyy.
Is there anyway I can do a check? Or it is the computer datetime setting?
A DateTime object isn't internally represented in days and months, so it doesn't actually have any native format per se. (There also isn't a DateTime.Today() method, but rather a property DateTime.Today)
A DateTime (which DateTime.Today returns an instance of) does have a ToString() method which is declared as:
public override string ToString()
{
return DateTimeFormat.Format(this, (string) null, DateTimeFormatInfo.CurrentInfo);
}
That CurrentInfo is going to be different for different users on the machine. Some operations will implicitly call ToString() (eg Console.WriteLine)
The good news is that there are overloads for ToString(), so you can do something like
Console.Write(DateTime.Today.ToString("dd/MM/yyyy"));
(Or any IFormatProvider)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With