date comparison function in php

$today = date("Y-m-d");
$expire = $row->expireDate; //from database

$today_time = strtotime($today);
$expire_time = strtotime($expire);

if ($expire_time < $today_time) { /* do Something */ }

3.75
4
A-312 69370 points

                                    dev:~# php
&lt;?php
date_default_timezone_set('Europe/London');

$d1 = new DateTime('2008-08-03 14:52:10');
$d2 = new DateTime('2008-01-03 11:11:10');
var_dump($d1 == $d2);
var_dump($d1 &gt; $d2);
var_dump($d1 &lt; $d2);
?&gt;
bool(false)
bool(true)
bool(false)
dev:~# php -v
PHP 5.2.6-1+lenny3 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 26 2009 20:09:03)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
dev:~#

3.75 (4 Votes)
0
4
10
Awgiedawgie 440220 points

                                    Select if(Date('2020-10-01') &gt; Date('2020-11-01'), '1', '2' ) as rslt_date

4 (10 Votes)
0
0
0
Awgiedawgie 440220 points

                                    $date1 = &quot;2021-01-15&quot;;
$date2 = &quot;2021-01-18&quot;;

if ($date1 &lt; $date2) {
 	echo &quot;$date1 is earlier than $date2&quot;;
} else {
	echo &quot;$date1 is later than $date2&quot;;
}

0
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
compare deux date en php integer comparison vs date php php get current date and compare php compare two dates to see which is more recent time compare php datetime compare dates php how does php compare dates? compare date and time in php compare string with date now php php get and compare date can be two dates is compare in php php string date compare compare date in php with time statement php compare dates if same day how to compare today date php datetime objects comparison php compare datetime object php php comapre dates time comparison php current datetime comparison php php dateand month compare php compare date with current date no time date comparisons in php compare two datestime in php compare dates same php how to compare 2 date inm php data php comparison compare dates in phph how to compare datetime objects in php how to compare current date and given date in php compare two time php compare two date in string php compare 2 datetime objects php php compare two date objects how to compare a date and a date that is subtracted in php comparer deux dates en php compare two date time in php php how to compare date strings compare two string date php compare dates php d/m/Y compare dates in array php diff bw two date in php diff bw two dates php check php date compare comparing sql datetime in php php compare DateTime Object php compare two dates to see if same day how to compare two date in php php current date compare php comapre two date and text compare date time php php to compare two dates datetime compare in php from current datetime php comparar duas datetime compare string to date php can php compare two dates compare two date minutes php php compare string dates php date comparison not working date compareto in php compare date with today php how to compare specific date from another date in php comapre date in php php compare two datetime is less than php how to compare time php compare dates as strings compare to date ranges in php php datetime comparison compare 2 date mysql php compare date ph compare two datetimes in php how to compare two date ranges in php classes with comparing dates php php compare formated dates compare two date strings in php compare length between date in php php compare mysql datetime php compare date year php date and time comparison php compare date and DateTime php time compare compare two dates and get difrrence in year in phpo php compare to date php compare date and string php compare to dates php compare date to today php date comparison with current date php compare two dats string to date compare php how to compare created_at date with current date in php COMPARE two dates sin php how to comapre with present date in php php compare 2 datetimes datetime objects compare php compare between two date php php time comparison php compare sql date php compare sql dates php comparing date timestamp php compare datetime with date compare datetime objects php php compare current date with past date Dates in php comparetion compare sql datetime in php compare sql date in php how to compare two date strings in php php compare date periods php compare date rangers how to compare date and time in php php compare date with current date php compare 2 dates without time comparer 2 dates en php php compare datetime to now compare datetime from database php php compare date string to now how to compare two dates php which are slightly seconds differenet compare day datetime php how to date compare in php how we compare teh two date using php function current date from date and expiry date compare php 2 date time compare php data to date compare php if condition compare 2 dates + php date compare in php in seconds how compare two date in php compare to date php PHP Logic, compare against specific date compare two time in php DateTime compare php php comparing datetimes compare date php bigger compare 2 date + php compare datetime in php compare 2 datetime php compare date function script php compare date script php compare current date with date in php php compare datetime minutes php compare date mysql how to compare date format in php how to comapre date in php how to compare days in php compare between two day php php is datetime compare php compare 2 datetimes are different php compare two dates m-y comparing datetime php php sql comparing dates compare 2 time php compare 2 date in php compare onl time in php string dates compare php diff_date in php compare date php sql time compare in php how to compare 2 dates in php php 7 \Datetime compare php \Datetime compare php compare dates with datetime comapre dates in php php compare 2 date time strings php date and time comparisons php date comparisons compare 2 date time in php comparing php datetime php compare datetime mysql php compare with today php date compare with today Compare time in php comparing date strings php php date diff date php compare dates without time compare date with time php php compare datetimes php compare date objects compare today date in php compare two datetime in php minits comparison of two dates in php comparison between two dates in php comparing dates in php now php mysql query date comparison php mysql compare dates compare two dates year in php how to compare tow date in php php compare two new datetime objects php compare two new datetime php compare new datetime compare php datetime convert date string and compare in php php compare two gmdate php compare dates equal to than php compare dates greater than comparing two date in php compare date time in php datetime comparison php comparing date time in php php compare 2 string dates php compare 2 date php datetime compare php compare dates with &gt; php compare two dates greater than php compare string date how to compare two dates php php comparing current date if statements compare date time with Now in php php compare datetime datetime comparison in php time comparison in php php compare date with today compare date for loop in php can i compare date strings in php php compare time how compare date in php diff date php with date diff date php php compare datetime objects compare date php php php compare dates in string how to compare date time in php date compare with current date in php php compare two dates with time php datetime compare two dates how to compare datetime with minutes in php php date string compare php comparing date strings datetime php compare comparer dates en php diff date in php comparing date php d-m-Y two date compare in php compare datetime php compare differences between two date php how to compare two time in php how to compare time in php php compare date time differance compare two datetime php php diff between two dates php compare date strings php compare dates &lt;=&gt; php comare dates compare two dates formats php compare format to a date php php get range between two date moment compare dates compare date in range ph comparing dates php compare to dates php php logic in matching a data in different time or date date comparesion in php php code compare dates compare two dates and get the difference in php delete data compare time sql php php compare dates as string date time match php compare &lt; and &gt; date in php check two date in php check two date php php match two dates php how to compare dates php compare dates and time compare php mysql date get difference between two dates in php php get dates between two dates compare between 2 date in php date range compare in php php equel date compare data php php equal dates php comparing several dates compare date php 7 if compare date php compare dates pgp difference entre 2 dates php how to comare created_at date to simplae date in php php create array of dates between two dates comparing date in php symfony 4 compare DateTimeInterface with datetime how to find the difference between two dates datetime class in php symfony compare two dates find greater date among two dates php get the difference between two dates in php php datetime compare date only php datetime compare dates date comparison function in php how to compate timestap php best option how to compare dates php php comparing date how to match two date in php php campare date compare time php php compare dates equal how to compare two different date in php best way to compare dates in php how to compare date in php php new datetime compare comparison between date php compare date php today php confront date compare two dates and minus php compare php dates how to compare date and time with old date and time in php php compare 2 datetime before date comparison in php how to compare two dated in php php compare two datetime datetime diff php compare tow dates datetime compare two dates php compare date and time with current date in php compare two dateTime objects php compare two string dates php make database date comparable with new date php 2 date compare php date comparison in php php compare dats php function to compare date compare 2 date php how to compare date with current date in php php Datime compare 2 dates php datetime compare 2 dates php date comparison compair date in php compare date which is greatther than in php compare date and time with current date inphp date match in php compare timestamp in php php diff 2 datetime how to compare datetime date in php how to check two date fields are in same date in php php check if date is minor then today php date comparasion comparing 2 dates php compare 2 dates php compare two date php php comare datetime date comparison php php check if 2 dates are older how to compare two dates in php how to compare two datetime php php compare datetime with current date time date compare php comparing dates in php php compare dattimle php function to compare 3 dates program to compare two month and year in php datetime php comparisons php comparint datetimme php date compare to now php datetime compare to now php comparing datetime compare two times php compare datetime with current datetime in php php compare two date string how to compare dates in php php date comper how to compare two dates in if condition in php compare dates using php php 7 compare dates copare 2 dates php date compare in php compare 2 dates in php php compare two date php compare two date strings compare date in php compare date php compare dates in php php datecompare php comparing dates php compare dat compare two dats php php compare date logical date comparison in php html php conpare date compare two dates in php php compare two dates compare dates javascript timestampdiff between two dates sql search between two dates in sql php compare 2 dates php date compare compare today's date in php compare two dates php compare two date in php php compare dates compare dates php
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source