How do you prefer to compare dates when it comes to OOP? What do you think about:
$date1 = new Date();
...
$date2 = new Date();
if ($date1 > $date2) {
...
}
Please do not put in example anything like strtotime etc., only OOP.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using PHP DateTime objects, you can compare dates using the standard comparison operators. For more info and examples, see the DateTime::diff manual page.
Here is example #2 from the manual: