Now: "2021-08-09T13:22:52.789Z"

useNow

Reactive current Date instance.

Usage

import { useNow } from '@vueuse/core'

const now = useNow()
const { now, pause, resume } = useNow({ controls: true })

Component

<UseNow v-slot="{ now, pause, resume }">
  Now: {{ now }}
  <button @click="pause()">Pause</button>
  <button @click="resume()">Resume</button>
</UseNow>
Learn more about component usage

Type Declarations

export interface UseNowOptions<Controls extends boolean> {
  /**
   * Expose more controls
   *
   * @default false
   */
  controls?: Controls
  /**
   * Update interval, or use requestAnimationFrame
   *
   * @default requestAnimationFrame
   */
  interval?: "requestAnimationFrame" | number
}
/**
 * Reactive current Date instance.
 *
 * @see /useNow
 * @param options
 */
export declare function useNow(options?: UseNowOptions<false>): Ref<Date>
export declare function useNow(options: UseNowOptions<true>): {
  now: Ref<Date>
} & Pausable
export declare type UseNowReturn = ReturnType<typeof useNow>

Source

SourceDemoDocs