Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Luxon Vue Countdown
<template>
<time>{{ remaining }}</time>
</template>
<script>
import { DateTime, Duration } from 'luxon'
export default{
data() {
return {
now: DateTime.local(),
counting: null
}
},
computed: {
remaining() {
return this.end.diff(this.now).toFormat('dd hh mm ss')
}
},
created() {
this.end = DateTime.fromObject({
year: 2019,
month: 11,
day: 3,
zone: "America/New_York"
})
},
mounted() {
this.counting = setInterval(() => {
this.now = DateTime.local()
if(this.now > this.end) {
clearInterval(this.counting)
}
}, 1000)
}
}
</script>
@LoveMeWithoutAll

This comment has been minimized.

Copy link

@LoveMeWithoutAll LoveMeWithoutAll commented Apr 30, 2021

nice example!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment