How to check if a certain date has passed?

So I want to expire access to a page if a certain date has passed. The user inputs their own date.

So for example, if the user inputs 2016-01-15 03:00 and today’s date is 2016-04-15 03:00 then the page access has expired.

My basic idea is to do a check to see if today’s date has passed the inputted date, but is there an easy way to do this kind of check with yii2 or PHP in general?

Something like

if date1 > date 2 { return false; }

Your approach is right. You can intercept in a filter, beforeAction(), etc…etc…