php compare dates without year -


i'm trying compare 2 dates. i've found many threads topic, in every thread there year. want achieve compare dates without year value. example:

if(31.07 > 16.11) {     // stuff } 

i tried following:

$sdaymonth = date("d.m", strtotime($row["date"])); $sdatecompare = date("d.m", strtotime("31.07"));  if($sdaymonth > $sdatecompare){     // stuff } 

unfortunately executes code in if statement. cannot figure out why. possible? if yes, doing wrong?

the variable $row row returned sql database, contains correct value.

why not pick constant year used in both dates you're comparing. way can still make use of strtotime().

$year = '2000'; $ts1 = strtotime($row["date"] . '.' . $year); $ts2 = strtotime("31.07." . $year);  if($ts1 > $ts2){      // stuff } 

alternatively, can concatenate $month , $day in order. way you're able convert these integer , compare them way, eg. aug 11 811 , nov 30 1130 , 1130 > 811.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -