vue-moment icon indicating copy to clipboard operation
vue-moment copied to clipboard

Filter style to convert UTC to local time?

Open nelson6e65 opened this issue 6 years ago • 3 comments

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') }}

nelson6e65 avatar Feb 04 '19 06:02 nelson6e65

Any update?

paladin2005 avatar Feb 20 '19 19:02 paladin2005

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>

ukgrant avatar Apr 10 '19 09:04 ukgrant

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>

Adizbek avatar Feb 11 '20 11:02 Adizbek