useTimeAgoIntl

useTimeAgoIntl

i18n対応のリアクティブな「○○前」表記。時間が変わると自動的に「○○前」文字列を更新します。Intl.RelativeTimeFormatによって提供されます。

使用法

import { useTimeAgoIntl } from '@vueuse/core'

const timeAgoIntl = useTimeAgoIntl(new Date(2021, 0, 1))

非リアクティブな使用法

リアクティブ性が必要ない場合は、formatTimeAgo関数を使用して、Refではなくフォーマットされた文字列を取得できます。

import { formatTimeAgoIntl } from '@vueuse/core'

const timeAgoIntl = formatTimeAgoIntl(new Date(2021, 0, 1)) // string