mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
16 lines
483 B
TypeScript
16 lines
483 B
TypeScript
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>;
|
|
};
|