$interval->format - change font color

i am using the following code to calculate the time difference between two values …


$dt1 = date_create($row['date_1']);

$dt2 = date_create($row['date_2']);

$interval = date_diff($dt1, $dt2);

echo $interval->format('%R%h:%i:%s');


my question … how can I change the color of the font to let’s say red when the value of $interval is negative
:slight_smile:

Use an IF statement to check the value of $interval and then echo out either the css style for the element or javascript code to change the font color. It depends on when you want the colour changed.