检查是否在结束前不到7天

时间:2019-03-19 11:43:45

标签: c# datetime

我正在尝试弄清楚如果球员的试用期即将结束时如何警告他。我想提前7天通知他们。

这是我到目前为止所拥有的:

DateTime now = DateTime.UtcNow;

string currDate = now.ToString("yyyyMMddHHmmss");
string trialDate = "20190320104842"; // This is how dates are saved in the DB

DateTime addDays = now.AddDays(-7);
string headupDate = addDays.ToString("yyyyMMddHHmmss");


if (System.Int64.Parse(currDate) > System.Int64.Parse(trialDate))
{
    print("TIME RAN OUT");
} 
else if( // NOT SURE WHAT TO USE HERE // )
{
    print("TIME RUNS OUT IN 7 DAYS");
}
else
{
    print("TIME STILL RUNNING");
}

不确定时间是否在7天以内?

感谢您的任何帮助,并在此先感谢:-)

0 个答案:

没有答案