如何从今天起x天数? [英] How to get x number of days from today?

查看:69
本文介绍了如何从今天起x天数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取今天的日期,并找到一个日期x未来的天数。因此,例如,我想查找从现在起30天的日期-我应该考虑使用哪个库?

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?

推荐答案

您可以使用 DateTime TimeSpan 结构。

You can use the DateTime and TimeSpan structure.

DateTime in30Days = DateTime.Today.AddDays(30);

TimeSpan days30 = TimeSpan.FromDays(30);
DateTime in30Days = DateTime.Today + days30; 

如果您需要 DateTime 和时间-时间段计算很重,您应该查看时间段库我可以推荐的.NET (开放许可)。

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.

这篇关于如何从今天起x天数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆