1

How would I go about checking if a certain date has passed?

The way this would work is; the program has 3 integers stored a day, for example: '28' a month: '3' and a year: '2019'.

How would I check if '28-3-2019' has already passed?

The program would return false if the current date is 27-3-2019 and should return true if the current date is 29-3-2019.

The code would be something like:

var date = 28-3-2019

if (date.Passed == true)
{
    //do something
}

The date could also be split into 3 ints ofcourse.

Marco
  • 56,740
  • 14
  • 129
  • 152

1 Answers1

5
DateTime date = new DateTime(year, month, day);

if(date < DateTime.Now)
{
    // date has passed. 
}
else
{
   // the date is in the future
}
Marco
  • 56,740
  • 14
  • 129
  • 152
Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171