useClock
This hook returns the current date time every second or a timeout
value.
Options
Name | Type | Description |
---|---|---|
timeout | Number | the time between the current and the next date value (default is 1000ms ). |
Return Values
a date
object of the current time.
Example Usage
tsx
import { useClock } from 'react-pre-hooks';
export default function Clock() {
const time = useClock();
return (
<main>
<p>{time.toUTCString()}</p>
</main>
);
}
import { useClock } from 'react-pre-hooks';
export default function Clock() {
const time = useClock();
return (
<main>
<p>{time.toUTCString()}</p>
</main>
);
}