Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this questionIf I do this:
DateTime now = DateTime.Now;
And then:
DateTime dt = new DateTime(now.Year, now.Month, now.Y开发者_运维百科ear, ..).AddDays(1);
It will take into consideration leap years and anything else that might be an issue with dates :)
I can't recall but I know .net 4 or 3.5 has new date time objects.
To save Jon Skeet from having to advertise his own project:
- Noda Time
Noda Time is a .NET library designed to simplify the correct handling of dates and times in the .NET environment. It is based on Joda Time, the industry standard date and time handling library for Java
The DateTime.AddYears() method does consider leap years.
精彩评论