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

amLocal do nothing

Open balicekt opened this issue 9 years ago • 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!

balicekt avatar Nov 26 '15 15:11 balicekt

<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

Hesesses avatar Dec 03 '15 09:12 Hesesses

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 avatar Dec 03 '15 12:12 balicekt

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 avatar Dec 03 '15 12:12 balicekt

@balicekt You did a great job. 👍

DreamRunnerMoshi avatar Aug 20 '17 14:08 DreamRunnerMoshi

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

Other combinations were unsuccessful.

SasaCetkovic avatar Nov 17 '17 16:11 SasaCetkovic