Reputation: 9930
I'm trying to take today's date and find a date x number of days in the future. So, for example, I want to find the date 30 days from now - what library should I look into using for this?
Upvotes: 0
Views: 2221
Reputation: 116
System.DateTime is the struct you need.
Examples:
DateTime.Today.AddDays(30); //30 days forwards
DateTime.Today.AddDays(-30); //30 days backwards.
Upvotes: 0
Reputation: 460288
You can use the DateTime
and TimeSpan
structure.
DateTime in30Days = DateTime.Today.AddDays(30);
or
TimeSpan days30 = TimeSpan.FromDays(30);
DateTime in30Days = DateTime.Today + days30;
If you need need DateTime
and time-period calculations heavily, you should have a look at the Time Period library for .NET (open license) which i can recommend.
Upvotes: 5
Reputation: 2531
You don't need a library, the .NET DateTime struct has all you need.
See http://msdn.microsoft.com/en-us/library/system.datetime.adddays.aspx for an explanation and example!
Upvotes: 1