Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

amLocal do nothing #208

Open
balicekt opened this issue Nov 26, 2015 · 5 comments
Open

amLocal do nothing #208

balicekt opened this issue Nov 26, 2015 · 5 comments

Comments

@balicekt
Copy link

Hi,

I tried this in my app:

am-time-ago="item.time | amParse: 'YYYY-MM-DD-HH-mm-ss' | amLocal"

but the result is same when is this w/ and w/o amLocal. Does anyone could tell me how to change a time to local? Thank you!

@Hesesses
Copy link

Hesesses commented Dec 3, 2015

<div>{{form.scheduled | amUtc | amLocal | amDateFormat : 'd.M.YYYY HH:mm' }} 
(<span am-time-ago="form.scheduled"></span>)
</div>

This is how i'm using the | amLocal and it works fine.
The problem I have its wih am-time-ago.. it compares the local time to utc time, not utc time to utc time

@balicekt
Copy link
Author

balicekt commented Dec 3, 2015

Thank you for answer Im a bit confused now. My problem is get UTC time from server for example: 2015:12:03 12:08:47 is my UTC server time and Im in Prague Europe it means I need to get time on device 2015:12:03 13:08:47 (it's +1) BUT: when I use this code: {{adversary.time | amParse: functions.getDateFormat()}} it prints "2015-12-03T11:08:47.000Z" WTF why? It looks like it takes my UTC time like as local time and it converts absolutely oposit right should be UTC -> LOCAL but it do LOCAL -> UTC. Do you have any adea how to make it work? Just print my server UTC time to Local time? Im getting crazy of it... same result when I use this code: {{adversary.time | amParse: functions.getDateFormat() | amUtc | amLocal}} also prints "2015-12-03T11:08:47.000Z"...

@balicekt
Copy link
Author

balicekt commented Dec 3, 2015

I think better way is do own filter. like this this:

'user strict';
angular.module('app')
.filter('utcToLocalAgo', function (moment) {
return function (value) {
return moment.utc(value, 'YYYY:MM:DD:HH:mm:ss' ).local().fromNow();
};
});

@DreamRunnerMoshi
Copy link

@balicekt You did a great job. 👍

@SasaCetkovic
Copy link

I made it work like this:
{{ comment.date | amFromUtc | amLocal | amTimeAgo }}

Other combinations were unsuccessful.

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

No branches or pull requests

4 participants