Questions tagged [angular2-moment]

Angular2 moment provides pipes for using momentjs methods in the angular environment. Make sure to include momentjs and angular tags along with this tag. Use angular-moment tag for the angularjs version of the library.

angular2 moment is a plugin that adds the following pipes to Angular based on the moment.js library.

  • Pipes
    • amTimeAgo - Use to format relative time
    • amCalendar - Format a date using moment.js calendar() method
    • amDateFormat - Format a date using moment.js format() method
    • amParse - Parse a custom-formatted date into a moment object
    • amFromUnix - Convert a unix-timestamp into a moment object
    • amDuration - Format a duration in a human readable format
    • amDifference - Get the difference between two dates in milliseconds
    • amAdd - Add hours, minutes or seconds from the specified date.
    • amSubtract - Subtract hours, minutes or seconds from the specified date.
    • amUtc - Create or switch the current moment object into UTC mode

References

Related Tags

46 questions
1
vote
1 answer

Angular2-moment, format to hours and minutes

I am trying to parse an object by key and modify one of the fields from seconds to Hours + minutes. tableData[key].forEach(weekday => { mappedObject[weekday.day] = weekday.spent; }); I've imported moment import * as moment from…
jsbeginner
  • 37
  • 6
1
vote
0 answers

Angular amTimeAgo not refreshing

I am trying to refresh amTimeAgo every time I call my function "resetDate" but it is not working. It is logging a correct new time in the console but the time does not refresh on the page. import { NgModule, Component, OnInit } from…
awtrimpe
  • 56
  • 4
1
vote
2 answers

Display Today, yesterday, tommorrow instead of dates in ionic

i am making an ionic app v2 in which i have to show 'today' instead of current date and 'yesterday' and 'tomorrow' also for respective dates. i tried using moment but it gives days till last week like last monday and reference time issue is also…
pelu
  • 83
  • 1
  • 7
1
vote
0 answers

Angular2 Moment invalid date

I've saved my Date with UTC format in my database. To show the date in the proper format is using angular2 moment. {{ task.updated_at | amTimeAgo}} | {{ 1517229284787 | amTimeAgo…
VinoPravin
  • 947
  • 3
  • 17
  • 32
1
vote
2 answers

Angular: Changing locale in moment has no effect

I use angular2-moment for handling dates in my app. I have one component that is used like datepicker with help of moment, now I am doing localization and I am stuck with localizing moment. I…
OjamaYellow
  • 899
  • 1
  • 13
  • 27
1
vote
2 answers

Implementing a dynamic Time Zone selector Angular 2/4/5

I need to build a TimeZone selector in my Angular 4/5 Application. When a user changes the timezone, I expect all displayed time values on the page to update immediately. I was planning to use: momentjs with timezone support using angular2-moment…
Deepak Kumar
  • 944
  • 9
  • 12
1
vote
4 answers

How to get date of last september dynamically with moment.js

I need the date of last September with moment.js - but dynamically. Current Date currentDate:string = moment().format('YYYY-MM'); // This will be 2017-10 How to know when the last september was from the current date? I need somethink like…
Vueer
  • 1,432
  • 3
  • 21
  • 57
1
vote
3 answers

Format date with angular2 moment

I'm getting following error, when using amTimeAgo pipe from angular2-moment. Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all…
Ned
  • 3,961
  • 8
  • 31
  • 49
1
vote
0 answers

bundle update failed: 'MomentModule' is not exported by node_modules\angular2-moment\index.js

I am using ionic2 + Angular2 and have installed "angular2-moment": "^1.0.0-beta.6". After I have imported I'm getting the following error Error: bundle update failed: 'MomentModule' is not exported by …
Abdul Rashid
  • 183
  • 1
  • 3
  • 11
0
votes
0 answers

After make an npm update the console shows Error: Module not found: Error: Can't resolve 'angular2-moment'

I was trying to install jquery on my Angular project and after write some jquery dependency on package.json doc and type npm update, the console says Error: Module not found: Error: Can't resolve 'angular2-moment'. Error occurs in the template of…
0
votes
1 answer

ng-idle-package-accessor-declared-in-ambient-context error in angular for ng-idle

I have installed ng-idle for browser time out. The functionality is working fine without compilation error but this error is showing ERROR in ../node_modules/@ng-idle/core/lib/eventtargetinterruptsource.d.ts(29,9): error TS1086: An accessor cannot…
0
votes
1 answer

get time in user timezone angular 5 + ngx-moment

I have response from server: dateCreated = "2019-02-06T14:43:50+03:00" And on UI I have: {{ dateCreated | amTimeAgo }} I want to see in result 1 hour ago, but I see 4 hours ago. What other pipe should I add here or how can I resolve that problem?
A. Gladkiy
  • 3,134
  • 5
  • 38
  • 82
0
votes
1 answer

How to add two hh:mm:ss format and get hh:mm:ss

I have below format of date and need a beloe o.p in momen var myDate="2019-01-26"; console.log(moment(myDate,'YYYY-MM-DD 00:00:00').add("2019-01-26 04:00"); expected o/p be 2019-01-26 04:00:00
Mohamed Sahir
  • 2,482
  • 8
  • 40
  • 71
0
votes
0 answers

Convert the CST time to local browser time

I am using Moment Js to convert the CST time to local browser time. My data is coming from back-end code is in "America/Chicago" timezone. I want to convert the "America/Chicago" timezone to Browser time. But date is not converted correctly. Below…
Maneesh Rao
  • 184
  • 4
  • 23
0
votes
0 answers

Moment js display different behavior of relative, calendar and multiple local support

I am using momentjs in an angular app and I don't have any code to show here. I tried to play around with it and try to figure it out but ended up in a mess. What I want to happen is I have a createdAt property that I am retrieving to some API…