category |
---|
Time |
Reactive time ago. Automatically update the time ago string when the time changes.
import { useTimeAgo } from '@vueuse/core'
const timeAgo = useTimeAgo(new Date(2021, 0, 1))
<UseTimeAgo v-slot="{ timeAgo }" :time="new Date(2021, 0, 1)">
Time Ago: {{ timeAgo }}
</UseTimeAgo>
In case you don't need the reactivity, you can use the formatTimeAgo
function to get the formatted string instead of a Ref.
import { formatTimeAgo } from '@vueuse/core'
const timeAgo = formatTimeAgo(new Date(2021, 0, 1)) // string