useNow

A React Hook that tracks the current date.

Demo

Now:
2026-01-21 11:45:15:362
isActive:
false
Now:
1768995915362
Update count:
0
GitHub

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