So what if you just override your ToString () method of a DateTime object? Could you then choose the desired format and each time it is used, it will be formatted the way you want, without worrying about it.
This is just a thought, so I don’t know if there are better solutions or not.
Then you can use the year, month, day properties to build it however you want. Sort of:
public override ToString(){
return this.Year + "-" + this.Month + "-" + this.Day;
}
Hi
source
share