SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $interval->format - change font color

    i am using the following code to calculate the time difference between two values ....
    Code:
    $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

  2. #2
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •