timestamp formatting vue component
This commit is contained in:
21
js/components/local_datetime.js
Normal file
21
js/components/local_datetime.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { format } from 'date-fns'
|
||||
|
||||
export default {
|
||||
name: 'local-datetime',
|
||||
|
||||
props: {
|
||||
timestamp: String,
|
||||
format: {
|
||||
type: String,
|
||||
default: 'MMM D YYYY H:mm'
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
displayTime: function () {
|
||||
return format(this.timestamp, this.format)
|
||||
}
|
||||
},
|
||||
|
||||
template: '<time v-bind:datetime="timestamp">{{ this.displayTime }}</time>'
|
||||
}
|
Reference in New Issue
Block a user