开发者

Find date after a given weeks(months) in ASP.NET

开发者 https://www.devze.com 2022-12-10 16:45 出处:网络
I want to find a date after a give weeks(months). For example, I开发者_如何学编程 want to find the date after 2 week from today or find the date after 4 month from today.

I want to find a date after a give weeks(months). For example, I开发者_如何学编程 want to find the date after 2 week from today or find the date after 4 month from today.

Thanks


do you want like ?

DateTime dt = DateTime.Now.AddDays(14);
DateTime dt1 = DateTime.Now.AddMonths(4);


DateTime.Now.AddDays(14)

to get the date 2 weeks from now

or

DateTime.Now.AddMonths(4)

to get the date 4 months from now

NB: This has nothing to do with ASP.NET. DateTime is part of the .NET BCL.


Two weeks after today:

DateTime.Now.Date.AddDays(2*7)  

Four months after today:

DateTime.Now.Date.AddMonths(4)  

Use DateTime.Date if you want only the date without current time (as in the sample).

0

精彩评论

暂无评论...
验证码 换一张
取 消