How can I tell if DateTime.Now() is on a day AFTER a different DateTime

后端 未结 5 1575
庸人自扰
庸人自扰 2021-01-23 17:43

I\'m running this on flutter, but I guess this could be a more general issue.

I am saving a DateTime in the preferences. I want to be able to then tell if DateTime

5条回答
  •  不要未来只要你来
    2021-01-23 17:58

    I cannot write a complete code for now but this is what it would look like:

    (pseudocode)
    
    expirationDay = lastDailyCheck.add(oneDayDuration);
    isOneDayAfter = DateTime.now().isAfter(expirationDay);
    

    You give an expiration date and compare the DateTime to that. You have to use isAfter for reliability, instead of .day check.

提交回复
热议问题