mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-26 07:13:41 +01:00
20 lines
424 B
Vue
20 lines
424 B
Vue
<template>
|
|
<time :datetime="date.toISOString()">{{ text }}</time>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import formatDistance from "date-fns/formatDistance";
|
|
|
|
const { date } = defineProps<{
|
|
date: Date;
|
|
}>();
|
|
|
|
const text = ref<string>();
|
|
function updateFromNow() {
|
|
text.value = formatDistance(date, new Date(), {
|
|
addSuffix: true,
|
|
});
|
|
}
|
|
useIntervalFn(updateFromNow, 30_000, { immediateCallback: true });
|
|
</script>
|