Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter style to convert UTC to local time? #114

Open
nelson6e65 opened this issue Feb 4, 2019 · 3 comments
Open

Filter style to convert UTC to local time? #114

nelson6e65 opened this issue Feb 4, 2019 · 3 comments

Comments

@nelson6e65
Copy link

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') }}
@paladin2005
Copy link

Any update?

@ukgrant
Copy link

ukgrant commented Apr 10, 2019

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>

@Adizbek
Copy link

Adizbek commented Feb 11, 2020

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants