0

I'm setting up an online dashboard for monitoring whether hardware is operational or not. This information is shown in a table. It would say when the hardware was 'last seen'.

I am able to get the date/time 'last seen' data in this format: 2022-05-25 12:15

The data becomes a table that won't inherently have any IDs.

What I would like to do is have the text 2022-05-25 12:15 change colour based on how long ago it was from the present time. For example, if it was 'last seen' more than ten minutes ago, the text would turn red to alert people that it needs to be checked out.

I am not handling the backend of this project, just the frontend.

How would I be able to change the colour of the text in the value based on how long ago it was?

Thanks!

Rory McCrossan
  • 319,460
  • 37
  • 290
  • 318
  • [Get table cell text](https://stackoverflow.com/a/14354714/519413), then [convert that string to a Date object](https://stackoverflow.com/a/5619588/519413), then [get the date difference in minutes](https://stackoverflow.com/a/7709819/519413) finally [add the class to the cell](https://stackoverflow.com/q/31682167/519413) if minutes is over your threshold. If you need more specific help than this, please edit your question to include your HTML as well as the code you've attempted to write so we can help you debug it. – Rory McCrossan May 26 '22 at 08:38

0 Answers0