to date should be greater than from date in Yii 2.0


Iam doing a project in apartment management system using YII 2.0. my module is facilities.iam having table facility_booking and fields are facility_name(varchar),facility_from(datetime),facility_to(datetime).facility_to date time should be greater than facility_from date time.if we entered wrong values it should give a warning. answer please thanks…

If we want to compare two dates we first have to convert them using strtotime.


echo &quot;msg1&quot;;


echo &quot;msg2&quot;;

Also you can use date_diff() function