JQuery TimeAgo library to change text color if DateTime is in the past?

I am using the Yarp jQuery TimeAgo library in my new application where I am showing the relative time for the Job being written in the Due Date field .

I just want to show the date / time value as RED text when the Date > value is in the past tense based on the current date.

So, real simplicity, Future Due Date will show green text by default with CSS on the page:
enter image description here

The past date will show red text:

enter image description here

The library can be found here: http://timeago.yarp.com/

Can anyone help me color the past text in Red?

The HTML on the page before the library converts it to future or past DateTime in words looks like this:

<time id="duedatetimeago"></time>

      

After the library does this magic on the element, it just looks like this ...

<time id="duedatetimeago">16 days ago</time>  

      

So you don't see any special CSS classes or data attributes or anything added, so it can be difficult to know when the current time is in the past. If you recognize "anyone" please share with me, thanks.

+3


source to share


1 answer


Here's a Gist containing the changes to timeago.js - you can change the default past and future colors in a variable inPastColor

on line49



+1


source







All Articles