JSON variable in PHP

0

I bring the fields of a table via JSON, they are printed perfectly as <td>{{data.Vence}}</td> . My problem is that I want to compare this date with today + 30 to see if it is lower and declare an alarm, but I could not do it since I can not access this date {{data.Vence}} .

<?php
    $t = strtotime('+30 days');
    $f = '{{data.Vence}}';
    echo $f; (ESTO FUNCIONA BIEN, hasta aquí)
    /*if (strtotime($f) < strtotime($t)) {
        echo "Rojo";
    }else {
        echo "Verde";
    }
    */
?>
    
asked by charlie 19.12.2018 в 21:25
source

1 answer

0

in php (if $ f and $ t are in format in -> yyyy-mm-dd), you can compare dates with the Datetime object. (there are other ways besides this)

$of = new \Datetime($f);
$ot = new \Datetime($t);

if ($ot < $of) ...
    
answered by 20.12.2018 в 00:40