Skip to content

Instantly share code, notes, and snippets.

@leemartin
Created October 6, 2019 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemartin/ff2a64a6116e938a526939becaa6821a to your computer and use it in GitHub Desktop.
Save leemartin/ff2a64a6116e938a526939becaa6821a to your computer and use it in GitHub Desktop.
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
Copy link

nice example!

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