You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
483 B
15 lines
483 B
import { dateTimeFormatTimeAgo, DateTimeInput } from '@grafana/data';
|
|
import React, { FC, useEffect, useState } from 'react';
|
|
|
|
export interface Props {
|
|
date: DateTimeInput;
|
|
}
|
|
|
|
export const TimeToNow: FC<Props> = ({ date }) => {
|
|
const setRandom = useState(0)[1];
|
|
useEffect(() => {
|
|
const interval = setInterval(() => setRandom(Math.random()), 1000);
|
|
return () => clearInterval(interval);
|
|
});
|
|
return <span title={String(date)}>{dateTimeFormatTimeAgo(date)}</span>;
|
|
};
|
|
|