This is great, thanks.
I've extracted it out to a function in plugins/filters.js, I find it easier to put really useful stuff in there and just drop that full file into new nuxt projects.
Vue.filter('formatDate', function (date) { const options = { weekday: 'short', year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false, } return new Date(date).toLocaleDateString('en', options) })
Added options to also format and show the time.
Result >>
Thu, October 22, 2020, 23:09
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is great, thanks.
I've extracted it out to a function in plugins/filters.js, I find it easier to put really useful stuff in there and just drop that full file into new nuxt projects.
Vue.filter('formatDate', function (date) {
const options = {
weekday: 'short',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
hour12: false,
}
return new Date(date).toLocaleDateString('en', options)
})
Added options to also format and show the time.
Result >>
Thu, October 22, 2020, 23:09