useNow
A React Hook that tracks the current date.
Demo
SourceNow: 2025-11-06 03:01:54:031
Usage
See API for more details.
Source
Click links below to view source on GitHub.
API
const now = useNow(options)
const { now, ...controls } = useNow({ controls: true, ...otherOptions })
Options
export type UseNowOptions<Controls extends boolean> = UseIntervalFnOptions & {
/**
* Expose more controls
*
* @defaultValue false
*/
controls?: Controls
/**
* Update interval in milliseconds, or use requestAnimationFrame
*
* @defaultValue requestAnimationFrame
*/
interval?: UseIntervalFnInterval
/**
* Callback on each update
*/
callback?: (now: Date) => void
}
Returns
Returns contain Pausable instance that can be paused, resumed.
See Pausable for more details.
If controls is true, returns an object with now and Pausable Instance, else returns the current Date instance.
export type UseNowReturns<Controls extends boolean> = Controls extends true ? { now: Date } & Pausable : Date