import React, { FC, useEffect, useState } from 'react'; import { dateTimeFormatTimeAgo, DateTimeInput } from '@grafana/data'; export interface Props { date: DateTimeInput; } export const TimeToNow: FC = ({ date }) => { const setRandom = useState(0)[1]; useEffect(() => { const interval = setInterval(() => setRandom(Math.random()), 1000); return () => clearInterval(interval); }); return {dateTimeFormatTimeAgo(date)}; };