1$today = date("Y-m-d");
2$expire = $row->expireDate; //from database
3
4$today_time = strtotime($today);
5$expire_time = strtotime($expire);
6
7if ($expire_time < $today_time) { /* do Something */ }
1dev:~# php
2<?php
3date_default_timezone_set('Europe/London');
4
5$d1 = new DateTime('2008-08-03 14:52:10');
6$d2 = new DateTime('2008-01-03 11:11:10');
7var_dump($d1 == $d2);
8var_dump($d1 > $d2);
9var_dump($d1 < $d2);
10?>
11bool(false)
12bool(true)
13bool(false)
14dev:~# php -v
15PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009 20:09:03)
16Copyright (c) 1997-2008 The PHP Group
17Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
18dev:~#
1$date1 = "2021-01-15";
2$date2 = "2021-01-18";
3
4if ($date1 < $date2) {
5 echo "$date1 is earlier than $date2";
6} else {
7 echo "$date1 is later than $date2";
8}