Skip to content

useTime

This hook allows you to get a Date object in real time that updates itself with a given interval.

{
interval?: number // By default 1000
}

The useTime hook returns a self updated Date object that can be used in your components:

import { useTime } from '@tecnosamba21/sam-hooks';
export function Time() {
const time: Date = useTime(500)
return <h1>{time.getTime()}</h1>
}