In our barangay system, there are only three (3) persons who can login in the system namely the Secretary, Treasurer and Book Record Keeper. One feature in this system is that if their term in their positions will come to and end, they cannot login in the system anymore. The crucial thing in making this feature is to compare Dates. Comparing dates is not easy but hopefully this can help you if ever you encounter this.
I tried using date_diff in comparing dates in reference to this website but it won’t work even if I copied the example and always getting this error
“date_diff() expects parameter 1 to be datetime”.
After several hours, I finally had the solution.
This is where the magic happens.
The variable $endTerm contains the date that is from MySQL then is converted to date which is in the variable $e_D. $e_c_D contains the current date. After that, these to variables needs to be prepared for comparison so date_parse is needed. date_parse returns an associative array. After that you can already use the variables $expiry_date and $current_date for comparison.