urish/angular-moment

amLocal do nothing

Opened this issue ยท 5 comments

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!

<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

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"...

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();
};
});

@balicekt You did a great job. ๐Ÿ‘

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

Other combinations were unsuccessful.