Timestamp: 1636077576692

useTimestamp

Reactive current timestamp

Usage

import { useTimestamp } from '@vueuse/core'

const timestamp = useTimestamp({ offset: 0 })
const { timestamp, pause, resume } = useTimestamp({ controls: true })

Component

<UseTimestamp v-slot="{ timestamp, pause, resume }">
  Current Time: {{ timestamp }}
  <button @click="pause()">Pause</button>
  <button @click="resume()">Resume</button>
</UseTimestamp>
Learn more about component usage

Type Declarations

export interface TimestampOptions<Controls extends boolean> {
  /**
   * Expose more controls
   *
   * @default false
   */
  controls?: Controls
  /**
   * Offset value adding to the value
   *
   * @default 0
   */
  offset?: number
  /**
   * Update the timestamp immediately
   *
   * @default true
   */
  immediate?: boolean
  /**
   * Update interval, or use requestAnimationFrame
   *
   * @default requestAnimationFrame
   */
  interval?: "requestAnimationFrame" | number
}
/**
 * Reactive current timestamp.
 *
 * @see https://vueuse.org/useTimestamp
 * @param options
 */
export declare function useTimestamp(
  options?: TimestampOptions<false>
): Ref<number>
export declare function useTimestamp(options: TimestampOptions<true>): {
  timestamp: Ref<number>
} & Pausable
export declare type UseTimestampReturn = ReturnType<typeof useTimestamp>

Source

SourceDemoDocs