php compare two dates

Solutions on MaxInterview for php compare two dates by the best coders in the world

showing results for - "php compare two dates"
Vanessa
20 Sep 2019
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 */ }
Sophie
12 May 2020
1<?php
2
3$datetime1 = new DateTime('2009-10-11 12:12:00');
4$datetime2 = new DateTime('2009-10-13 10:12:00');
5
6if ($datetime1 > $datetime2) {
7    echo 'datetime1 greater than datetime2';
8}
9
10if ($datetime1 < $datetime2) {
11    echo 'datetime1 lesser than datetime2';
12}
13
14if ($datetime1 == $datetime2) {
15    echo 'datetime2 is equal than datetime1';
16}
Salvatore
09 Aug 2017
1$date1 = new DateTime("now");
2$date2 = new DateTime("tomorrow");
3
4var_dump($date1 == $date2); // false
5var_dump($date1 < $date2); // true
6var_dump($date1 > $date2); // false
7
Sofia
11 Sep 2017
1$date_now = date("Y-m-d h:i:s");
2$variable = new DateTime($date_now);
3$to_compare = "2018-06-01 12:48:09";
4$variable1 = new DateTime($to_compare);
5$difference = date_diff($variable, $variable1)->format("Difference => %Y years, %m months, %d days, %h hours, and %i minutes");
6echo $difference;
Stefania
27 Aug 2018
1$period = new DatePeriod(
2     new DateTime('2010-10-01'),
3     new DateInterval('P1D'),
4     new DateTime('2010-10-05')
5);
6
7//Which should get you an array with DateTime objects. 
8
9//To iterate
10
11foreach ($period as $key => $value) {
12    //$value->format('Y-m-d')       
13}
Diego Alejandro
07 May 2018
1Select if(Date('2020-10-01') > Date('2020-11-01'), '1', '2' ) as rslt_date
queries leading to this page
php check if datetime is between two datesmatch 2 dates and return days phpphp compare date is todayphp how to compare datesphp compare two date stringscomparing two dates in phpcompare 2 datetime objects phpphp get date difference in daysdate between phpfind greater date among two dates phpphp compare 2 dates without timephp compare to dateshow to compare current date and given date in phphow to match two date in phpdiff bw two date in phpfind all date staring to end date phpphp get current date and compareget date array in between two dates phpcompare two date time in phpprogram to compare two month and year in phpfind all dates between two datesphp function to compare 3 datesdates between phpphp compare time stringsdatetime between two dates phpget date count between two dates in phphow to compare two dates php which are slightly seconds differenetphp date and time comparisonshow to compare two dates in if condition in phpphp how to compare date stringswhere date between phpget all dates between two datesphp compare datetime to nowget date time between two dates excluding weekends phpget all days between two dates phppphp get all saturdays between two datesphp get array of first and last dates between datesphp compare date periodscompare string with date now phpphp mysql date between two dateshow to compare two date ranges in phpphp query between two datescheck if date is between two dates phpcompare tow date in phpget date difference between two dates in phpcheck if date between two dates phpfetch data between two dates in phphow to compare datetime objects in phpcompare two dats phpcompare dates pgpphp get date between two dateshow to compare date and time in phphow to get difference between two date in phpget date random between two dates in phphow to find date difference in phpphp comare datesshow date between two dates phpstart date to end date bitween date in array in phpcoparing time and date in phpdatetime compare dates phpcompare datetime objects phpphp generate array of dates between two datesdifferent between two dates in days and month phpdifferent between two dates phpphp add two dateshow to print full year dates between two dates in phpphp compare sql datescurrent datetime comparison phphow to get each date between two dates in phpphp datediffhow to compare two date in phphow to check if there is a date in an array which is between two other dates phpdatetime compare in php from current datetimehow to compate timestap php best optionphp compare dates in arrayhow to compare two different date in phpdata to date compare php if conditioncompare two datetimes in phpfind difference between two dates script phpdate comparesion in phpphp foreach date between two datesphp compare two new datetime objectshow compare two date in phphow to check between two dates in phpcompare length between date in phpcompare 2 date phpfilter dates between two dates phpdate differ 1h of dates in phprange of dates phpdiff date phpphp compare two datetimephp 7 5cdatetime comparelogical date comparison in phpphp dates between two datesphp start date and end date get rangehow to use array od dates phphow to date compare in phpdifference entre 2 dates phpcalculate difference between two dates phpget time between two dates phpcompare day with timestam phpget array of dates between 2 dates phpfind all dates between two dates in phpdate compare with current date in phpdiff bw two dates phpwrite a for loop that saves the date numbers to the array dates 5b 5d check curent date between two dates phpphp compare timestamp date onlyphp campare datecompare 3c and 3e date in phpphp confront datephp datetime difference in daysphp create array of dates between two datesphp compare two date objectscompare date with time phphow to create array of dates in a year in phpphp compare two date stringbetween two dates php sqlfind diffrent date between two dates in phpcompare php datetimephp compare new datetimephp is datetime comparephp compare datesphp date range between two dates with example2 date compare phpsearch data between two dates in phpphp get diff between two datescan i compare date strings in phpphp compare two dates with timephp create date between two datecanwe compare string in date in phpphp compare tow datescompare two dates and get difrrence in year in phpocompare 2 dates php y m dphp date filter range between two dates with examplephp get all dates between two dateshow to get time difference between two dates in phpphp date range between two datesphp foreach day between two datescompare date and time with current date in phpcomparing dates in phpcompare to date phpphp to foreach select number between two datescopare 2 dates phpphp compare datetime with current date timecompare 2 time phpcompare date in php with time statementcompare format to a date phpphp list date between two timestampcheck if a date is between two dates phpcompare date php biggerhow to get date between two dates in sql phparray of dates phpphp datetime compare date onlyget start date and end date from date range in phpcompare date in dabase and current date in phpget array of dates from current date to next end of month phpbetween date phpphp all days between two datesphp date comparison not workingcan be two dates is compare in phpphp compare two dates to see if same daytimestamp date compare previous some date phpget all selected days in a period phpcompare date time column to current date time phpcreate date range from two dates phpphp date comperphp compare datscheck date between two dates in php mysqlcomparing two date in phpcount day between two dates phpphp date range arrayphp datetime comparehow to check results between two dates phpcompare php datescomparing 2 dates phpcompare datetime phpphp calculate date difference in daysphp compare two datetime is less than todaytime between two dates phpcompare datetime with date phpphp find days between two datesdifference between two dates in php date 28 29how to find if date is between to date phpphp compare latest to current dateget each date between range phpphp where between datephp compare two dates greater thancompare today 27s date in phpmatch two different dates phptimestamp comparison in phpcompare two date strings phpphp compare dates with 3eget all dates between two dates php in arrayhow to get between dates of start and end dates in phpcomparing date time in phpcompare two time string phpget all days between two dates phpget all dates from two dates2 date time compare phpphp compare 2 date time stringsphp check if date between two dateshow to get date difference in days in phpdifferent tow date in phpphp get list of dates between two datesphp mysql query date comparisoncompare 2 date mysql phpcurrent date from date and expiry date compare phpphp compare dates in stringphp get dates arraygenerate a list of dates between two dates phpphp generate array of dates for the next weekcompare two date phptime compare phpdiff date in phphow to show datetime between start date to end date in phpin php find data through given two datesphp compare to datephp sql between two datescompare two dates year in phpcurrent date comparison in phpphp compare date string to nowhtml php conpare datephp compare date time differanceget all the dates between two dates in phptime comparison in phphow to get number of days between two dates phpcompare two dates sin phpdifferent date in phpphp difference between two datecompare time 28 29 phpphp check if current date is between two dateshow to get the difference between two dates phpphp string date comparedays between two dates phpcompare to date ranges in phpphp date difdays between two datetime phpphp compare dates equalphp check if between dates phpcompare date time with null phpconvert between dates phpphp equal datescompare two dates and minus phpcompare date php d m yphp array between two datesphp comparing several datescompare 2 datetime phpphp datetime betweenget difference between two dates in days phpphp array of days between dateshow to compare current date with other date in phpcompare two dates phpget all the between dates from start and end date phpdifference of two dates in phpcomparer deux dates phpcheck date in between two dates phpget all dates from 2 dates phpcompare datetime object phpphp date comparisonsfind difference between two dates and time in phpphp create date range arrayhow to calculate dates between dates in phpcompare 2 dates in phphow to compare a date and a date that is subtracted in phpcompare date php todayget all dates from date difference phphow to compare date format in phpphp compare two datsphp compare date todayphp date difference in daysphp compare date stringsphp check if date is minor then todayphp comapre 2 dategenerate dates between two dates phpcompare dates in phpphp date comparedate calculator between two dates phptime compare in phpphp compare 2 datetimes are differentcompare days phphow to calulate between two dates in phpphp get all dates between two dayscompare current date with another date in phpcompare two dates in phpphp compare two datetime objectshow much time between 2 dates phpif compare date phpcompare 2 date 2b phpphp if 2 dates is between todayphp date interval between two datesphp time compareget difference between two dates in minutes phptwo date difference in date in phpcalculate the difference between two dates using phpphp date string comparephp compare dates as stringphp diff between two datesphp range of dates within a yearphp comparing date timestampcan we compare dates in phpcompare current datetime phpcompare date php phpphp comapre datescompare two date string in phpdifference between two dates in phpphp compare mysql datetimecomparison between date phpphp compare 2 datephp compare date with todayif there is a date between two other dates in an array phpcompare timestamp in phpfilter data between two dates in phpcomapre date phpphp compare dates as stringscompare deux date en phpcompare 2 date time in phpif date between phpphp function to compare datecompare date function script phpphp comparing datesphp compare datetime minutesphp get number of nights between two dateshow to comapre with present date in phpforeach create select between two datescomparer 2 date phpphp 5cdatetime compareget dates from 2 dates in phpdifrence between two date and time in phpphp to compare two dateshow to calculate between two dates phpphp compare date and datetimehow to compare time in phpcomparing date in phpdate range php conditiondelete data compare time sql phphow to get dates between two datescompare two datetime in phphow to compare specific date from another date in phpphp current date comparedatetime comparison in phpcompare 2 dates phpsearch date between two dates in php arraycompare 2 date in phpget the difference between two dates in phpphp compare datcheck two date phpget date array between two dates phpphp date diff datehow to pick data between 2 date behind today in phphow to make an array of dates in phpno of dates between two dates phplist dateinterval between two dates phpphp comapre two date and texthow to find the date and time is between the two date and time or not in phpdate between todate difference in phpphp date difference in daycomparer dates en phpphp list dates between two timestampphp compare string datehow to compare dates phphow to get current date and compare it with future date in phpdate compareto in phpcomparer date en phpcompare date with current date in phpcompare date and time in phpcompare date php sqlhow to compare two date strings in phpphp get every monday between 2 datesphp compare two dates m yhow to find the difference between two dates datetime class in phpwhere date equals to date in phpdisplay dates based on two dates given using phpdate range compare in phpcompare two datws in phpcheck date is between two dates or not in phpphp check date is between two dateshow to compare date time in phpfunction date between two dates phpcompare two str dates phpcan we compare two dates in phpprint all dates between two dates in phptime comparison phpcompare two timestamps phpcurrent date is between two dates phpphp check if date is between two datesconvert date range to arrayphp compare with todaydate time match phpmake list of dates from two dates phpphp dateand month comparedifference two dates in phpget all dates between two dates in phpphp calculate days between two datesphp logic in matching a data in different time or datecompare dates in phphphp comparing date stringsphp compare dates without timephp compare dates 3c 3d 3edate comparison in phpcheck if current date is between two dates phpcomapre date in phpclasses with comparing dates phpcompare date script phpcheck if today is between two dates phpget dates betwen dates phpphp how to check 4 dates betweenphp code compare datesdate comparison function in phphow to decode date range url in php get methodhow to compare date value in phpcompare date and time phpphp compare formated dateshow to check if a date lies between two dates in php how to compare 2 date inm phphow to compare today date phpdata php comparisonphp compare dates with datetimehow to compare 2 dates in phpcreate array of dates in phpdates compare phpdate compare in phpcompare dates datetime phpphp compare date objectshow to get date difference in phpdifference between two date phpdate match in phpcompare date phphow to compare two dated in phpcheck two date in phpphp compare current date with past dateselect where date equals to date in phpcompare datetime in php value from mysqlphp get dates between two datescomapre dates in phpget array dates phpphp get difference between two datesphp days between two dateshow to comare created at date to simplae date in phpget amount of days between two dates phpcompare date in phpcompare dates phphow to compare dates in phphow we compare teh two date using php functioncompair date in phpphp compare date and stringhow to get data from database between two dates phphow to compare if two date arre equals phpinteger comparison vs date phphow to check if date is in between two dates phpadd dates and calculate difference phpphp date time to date and twodate comparisons in phpcompare two time phpphp dateintervarl between two datecompare datetime with current datetime in phpphp difference between two dates in daysget year list of array date in phpcompare date time with now in php how to generate date between two dates in phpphp datetime compare two datesphp datecomparestring dates compare phpget two dates difference in php excluding sunday betweenphp compare dates equal to thandifference between two dates php daysminits comparison of two dates in phpreturn all dates between two dates in an array in phpphp get time between two datesphp check if between datescompare between two date phpph code to get all dates between two daysphp print all dates between two datesphp return month between two datescompare dates php d 2fm 2fyphp time comparisoncompare datetime in phphow much day between 2 dates phpget each date in the year phpphp pass date to compare in mysqlfor loop between two dates in phpcompare two datetime phpcompare two datetieme phphow to compare created at date with current date in phphow to find saturday date between two dates phphow to compare tow date in phpphp check if datetime is between two datetimescompare current date with date in phphow to compare days in phpphp get days from two datescompare to current date in phpdatetime objects comparison phpdatetime compare phplist of date between two dates phpbetween date in phpphp range of dates between 2 dates arraycompare two dates and get the difference in phpphp array of datescompare dates using phpcompare date and time with current date inphpbefore date comparison in phpphp how to get date from listget two date difference in phpstring date less than now phphow to compare date and time with old date and time in phpcompare date between two datetime phpphp get time between 2 datesdatetime comparison phphow to get length between two dates in phptwo date compare in phphow to compare data base and with current date in phpcompare two time in phpdifference between dates phpget date difference in years in phpphp compare 2 string datescompare dates javascriptphp compare date with current date no time php equel datephp check if today is between two datesbetween the date in phpphp date comparison with current datesearch between two dates in sqlphp compare dates greater thanphp compare datetime with datecompare day datetime phpphp 2 datetime from same datetimediff date in phpcompare date php 7how to get data from sql in php between two datesphp datetime comparisoncompare two date in string phpwhere between date phpphp return the earlier of two datescompare two array date difference in phpdate between dates php 24startdate 3d substr 28 24request 3edaterange 2c 0 2c 10 29 3bphp check if date falls between two datesphp between two datesget all dates between two dates phpphp filter data between two datesphp compare two datetime is less thanphp get range between two datephp create date array from start and endphp get and compare datephp comparing current date if statementsphp compare dates if same daytwo date compare phploop between two dates phpcompare data phphow does php compare dates 3fdatetime php comparehow to get days between two dates in phpphp array of days and timesphp query date range between two datesphp create date range array with league periodphp check between two datescompare 2 dates in php month diff betweenhow to get date between two date in phpphp difference entre 2 dateshow to get all dates between two datesfind dates between two dates phpget from and to date from daterange phparray of dates between two date phpphp date betweenphp sql comparing dateshow to compare timestamp in phpphp date compare to nowhow to find time interval betweeen 2 dates in phphow to get dates between 2days in phpcompare two string dates phpduplicate range of data anche date phpphp where date betweencompare date and time with current date and time in phpdate between in phpcompare date phphp compare datetime objectsphp compare datetimesphp compare date to todayphp compare datetimedates between two dates phpcompare to date in phpdate compare phpget the difference between two date in phpcomparing sql datetime in phphow to check two date fields are in same date in phpcompare time phpdifference in day between two dates in phpphp html display data between two datesdateinterval between two dates phphow to compare two dates in phpbest way to compare dates in phpget difference between two dates in phpdate comparison phpphp compare string datescompare between 2 date in php how to get number of days between two dates in phpphp month between two datesphp create arrays with all dates between two datescomparing sql datetime in php and print if today date and timedifference between two dates phpphp compare dateget list of dates between two dates phpcompare two date minutes phpphp compare date from mysql datephp get a todays date and compare itcompare onl time in phpphp compare two gmdatecompare to date in php output daybetween dates phpcomparing dates using phpcompare dates same phpphp get date rangecompare date which is greatther than in phpphp compare datetime objectdate compare in php in secondshow to find number of days between two dates in phpcompare sql datetime in phpdays between dates phpcompare 2 dates 2b phpphp get days between two datescompare date in range phcompare to dates phpphp compare two datephp code for compare two date for get olderst datecompare two datetime objects phphow to compare date with current date in phpcalc difference between two dates phphow to create an array with dates in phpphp check if date and time is between two datesphp date comparisonphp check if 2 dates are olderhow compare date in phpphp compare two dates to see which is more recentphp compare two new datetimecomparing php datetimephp get day between two datesphp how to compare timecomparer 2 dates en phphow to get a date range in phpphp create end date between two datescompare string to date phpcompare time phpcopmare two date object phpcompare time in phpphp between datehow to compare date in pphpphp compare 2 dates less than or equal todaycompare two times phpphp make date array between two datescreate array of date from range datephp query wp posts between two dates php date in arrayphp compare 2 datetimesphp time between two datetimesdates in array phpcompare date with today phpcomparing datetime phpphp compare 2 datetimes are equalshow to list days from date range phpdatetime objects compare phpget dates from an array phpphp compare 2 datetimephp between date rangesubtract between two dates in phpphp date compare with todaycheck today date is between 2 dates in phpphp compare dates from dbphp date comparasioncompare with today date phpcomparison of date in phpphp get day difference between two datesphp compare date with current datestart date and end date compare in phpget between dates in in phpphp compare timecreate date interval array of 1 week phpphp compare date to nowphp loop between two datesphp comparing datetimescompare 2 date times phpcompare differences between two date phptwo dates difference in php comparecalculate days between two dates in phpphp difference between two datescompare two date in php php get all days between two datesfind dates between two dates in phpdifference between 2 dates in phpdate time comparision in phpcomparing dates phpphp array between two dates if is date show div else show other divhow to show date between start and end date in phpphp date compare onlyconvert date string and compare in phphow to get year from date array in phpget difference between two dates phpcheck date between two dates in php arraycompare two dates formats phpphp compare date yearphp compare two datesdifference between two dates php in dayscompare 2 date in second phpdates in php comparetionlist dates between two dates phpphp datime compare 2 datescomparing dates in php nowphp compare date mysqlcompare sql date in phpdiff date php with datephp comparing datechange date to compare with date in database phphow to compare two dates phpcompare datetime from database phpfind all date staring to end date php in array compare two datestime in phpcompare today date in phpcompare date time phpcheck php date comparephp how to check if a date falls between two other datescompare dates in array phpphp 7 compare datescompare two string date phpget days between two dates in phpcan php compare two dateshow to compare date in phpphp date and time comparisoncompare date for loop in phpphp match two datesphp check if two dates are between todayhow to compare two time in phpphp datetime compare datestimestampdiff between two dates sqlphp if date betweencompare between two day phpphp between datesstring to date compare phpcheck date between two date in phpdate interval compare in phpcomparer deux dates en phpphp array get the date betweencomparing date strings phpget date difference in phpphp logic 2c compare against specific datephp daterange days arrayget dates between two dates phpcompare two date strings in phpprint date between two dates phphow to create array of dates in phpphp date equal todaydifference between two date in php into date formathow many firadaies in range of date phpphp compare sql datehow to check from date and to date between another from and to dates phpdifference between dates in phpphp compare 2 datescompare string to datetime phpphp datetime compare 2 datescomparing sql datetime in php and print if today date php date betweencompare date time in phpcompare time php without datephp compare two dates