Convert a date and time in a OH3 page cell to "x minutes and hours ago "

Tags: #<Tag:0x00007fc910e526e0> #<Tag:0x00007fc910e52438> #<Tag:0x00007fc910e51f60>

Hello,

I’m searching for help please. I have a cell in a OH3 page that shows the date and time of the last update from a item:

cell

yaml:
component: oh-label-cell
config:
item: GES_INCENDIO_QUARTO_LU
title: QUARTO - DETETOR
footer: Ultima atualização
icon: f7:asterisk_circle_fill
action: analyzer
actionAnalyzerChartType: day

My goal is to show something like “1 hour and 14 minutes” instead of time anda date.

Thank you so much for reading this and keep safe.

Hey @Antonio_Laranjeira and welcome to the community

have a look in the MainUI docs to see whats possible - the dayjs library is the thing you’re looking for. Find more informations on that in the official docs:

The .fromNow() function should suit your needs.