vue-moment
vue-moment copied to clipboard
Filter style to convert UTC to local time?
I can make this to work with:
{{ $moment.utc(user.updated_at).local().fromNow() }}
{{ $moment.utc(user.updated_at).local().format('L LTS') }}
But I would like to, instead, use something like:
{{ user.updated_at | moment('local', 'now') }}
{{ user.updated_at | moment('local', 'L LTS') }}
Any update?
I was looking for a way to achieve this. Ended up using a custom filter for now.
Vue.filter('utcAsLocal', function (value) {
return moment.utc(value).local();
});
<div>{{ user.updated_at | utcAsLocal | moment('L LTS') }}</div>
I have created filter similar to moment. Inspired by comment above
Vue.filter('localMoment', function (date, format) {
return moment.utc(date).local().format(format)
})
Usage
<td>{{r.ORDER_DATE | localMoment('hh:mm DD-MMMM YYYY')}}</td>