string - php Greater Than Comparison Not Working -


i'm looking highlight rows when child 12 years , older rows highlighting.

in nutshell, here data.

i'm getting birth date here:

      // getting birth date string         $birthdatein=strtotime($birthdate);         $newdate=date('y-m-d',$birthdatein); 

i'm getting age of child of today here:

        // getting date difference between birthdate , today         $birthdatein = new datetime(''.$newdate.'');         $todaydatein = new datetime('today');         $age = $birthdatein->diff($todaydatein); 

i'm looping through mysql query results, , displaying age in format:

        echo "<td>" . $age->format('%y years %m months') ."</td>"; 

then, code sets age of child in 2020 (this works):

        //get age dec 2020           $setdec2020 = new datetime('2020-12-31');                    $ageondec2020=$birthdatein->diff($setdec2020); 

now, here problem. i'm using code display green span if age of child on 12 years of age, otherwise, yellow:

        if ($ageondec2020 > 12)         {                $ageondec2020display = "<span style='background-color: #98fb98'>".$ageondec2020->format('%y') ."</span>";         } else {              $ageondec2020display= "<span style='background-color: #ffff00'>".$ageondec2020->format('%y') ."</span>";         } 

then, display such:

            echo "<td>" . $ageondec2020display ."</td>"; 

the output highlighting yellow when not of values on 12. think has "strings" , "integers" in "if" statement -- not sure next.

any ideas?

thanks lucky chingi direction, added if statement, , world:

  ($ageondec2020->format('%y') > 12) 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -