Skip to content

Instantly share code, notes, and snippets.

@paltman
Created October 24, 2018 14:58
Show Gist options
  • Save paltman/06ffcd6d7bb41da3bbc7e26328f19ce4 to your computer and use it in GitHub Desktop.
Save paltman/06ffcd6d7bb41da3bbc7e26328f19ce4 to your computer and use it in GitHub Desktop.
// components/PrettyDate.vue
<template>
<span v-if="date" class="pretty-date" :title="date">{{ formattedDate }}</span>
</template>
<script>
import { format } from 'date-fns';
export default {
name: 'pretty-date',
props: ['date'],
computed: {
formattedDate() {
return format(this.date, 'MMM dd');
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment