Questions tagged [angular-moment]

AngularJS directive and filters for Moment.js. Angular moment provides the `am-time-ago` directive and a number of filters that include `amParse`, `amFromUnix`, `amUtc`, `amUtcOffset` and `amLocal`. Make sure to include momentjs and angularjs tags along with this tag.

Angular moment is a plugin that adds the following directives and filters to AngularJS based on the moment.js library.

  • Directives
    • am-time-ago - Use to format relative timestamps
  • Filters
    • amDateFormat - Format a date using moment.js format() method
    • amDurationFormat - Format a duration in a human readable format
    • amCalendar - Format a date using moment.js calendar() method
    • amTimezone - Apply a timezone to the given date or moment object
    • amLocal - Change the given moment object to be in the local timezone
    • amUtc - Create or switch the current moment object into UTC mode
    • amUtcOffset - Use the given UTC offset when displaying a date
    • amFromUnix - Convert a unix-timestamp into a moment object
    • amParse - Parse a custom-formatted date into a moment object
    • amAdd - Add hours, minutes or seconds from the specified date.
    • amSubtract - Subtract hours, minutes or seconds from the specified date.
    • amDifference - Get the difference between two dates in milliseconds
    • amStartOf - Mutate the original moment by setting it to the start of a minute, hour or day of time.
    • amEndOf - Mutate the original moment by setting it to the end of a minute, hour or day of time.

References

Related Tags

197 questions
114
votes
8 answers

Get timezone from users browser using moment(timezone).js

What is the best way to get client's timezone and convert it to some other timezone when using moment.js and moment-timezone.js I want to find out what is clients timezone and later convert his date and time into some other timezone. Does anybody…
nemo_87
  • 4,523
  • 16
  • 56
  • 102
78
votes
4 answers

Extract time from moment js object

How do i extract the time using moment.js? "2015-01-16T12:00:00" It should return "12:00:00 pm". The string return will be passed to the timepicker control below. http://jdewit.github.com/bootstrap-timepicker Any idea?
ove
  • 3,092
  • 6
  • 34
  • 51
48
votes
2 answers

Moment.js - Parse Date Time Ago

I am saving my date like this in my mongo database: Thu Oct 25 2018 17:30:03 GMT+0300 (EAT) I would like to use moment.js to have in the front end like 1 hour ago or 3 hours ago. How would I go about this?
Dng
  • 633
  • 1
  • 8
  • 14
36
votes
5 answers

"moment" has no exported member 'default'

I'm using moment.js to change the local date format for my application but getting the following error: "moment" has no exported member 'default' when importing the library. Below is my code: import {Inject, Injectable, Optional} from…
Amit Golhar
  • 799
  • 4
  • 8
  • 21
26
votes
6 answers

How to Include moment-timezone in Angular 2 App

I realize, this question is repeated but previous once does not provide apt answer moment package was already installed 1.Installed package npm install moment-timezone --save Inside node_modules…
Sandeep Chikhale
  • 1,505
  • 2
  • 21
  • 36
20
votes
1 answer

Angular Moment : Moment Timezone has no data for America/New_York

Date received from server is in UTC timezone and I need to convert it to a particular timezone, for example : America/New_York .Following is the code for same
Aman Gupta
  • 3,627
  • 4
  • 40
  • 64
12
votes
2 answers

Moment.js amDateFormat always returning date from 1970

http://plnkr.co/edit/5zxXEEz30t51yGhgYWVF?p=preview I'm using Moment.js and Angular-moment in my app. For some reason it's converting all my epoch timestamps to the same date from 1970. {{tag.added_epoch | amDateFormat:'dddd,…
Leon Gaban
  • 36,509
  • 115
  • 332
  • 529
8
votes
3 answers

How can I set a valid empty date in Moment js?

So, I am using an Angular material datepicker which only helps me select a month and a year. https://material.angular.io/components/datepicker/overview#watching-the-views-for-changes-on-selected-years-and-months However, the functionality doesn't…
8
votes
2 answers

How to format 'angular-moment's 'am-time-ago' directive?

LIVE DEMO I use the am-time-ago directive to show a relative timestamp: By default, it is formatted as "a day ago", "5 days ago", etc. How could I change the formatting to be "1d", "5d", "3h", etc?
Misha Moroshko
  • 166,356
  • 226
  • 505
  • 746
7
votes
1 answer

Angular2 clock update every second

I've followed the Tour of Heroes tutorial, and I'm now in the process of modifying the project. My project will have a lot of clocks and timers, and my first task is to make a clock that displays the UTC time. With the MomentModule, I'm able to…
Christian
  • 195
  • 1
  • 2
  • 10
6
votes
4 answers

angularjs moment parse format

I have a ng-repeat that display the following expression {{date}} // 2-1-2017 When I use angular-moment {{date | amDateFormat:'DD'}} I got 1, which I'm expecting 2. how to make moment know my format is actually dd-mm-yyyy not mm-dd-yyy in the…
Jessie Emerson
  • 743
  • 4
  • 12
  • 25
5
votes
5 answers

moment is giving me error in angular 5 html template

I am using moment v2.22.0 in angular 5, and this is how I have imported it in module - import * as moment from 'moment'; and using it in component as - export class ChatComponent { . . . public moment: any = moment; . . } and when I am…
samar taj Shaikh
  • 1,165
  • 11
  • 18
5
votes
2 answers

momentJS default locale is zh-tw and can't seem to overwrite it

I'm pulling the momentJS library from a CDN in my Angular app: The default locale is supposed to be English ('en'). But for some reason, the default…
AlexG
  • 1,596
  • 2
  • 17
  • 26
5
votes
1 answer

Get week day in portuguese language from date in moment js

This is my code $scope.getWeekDayShort = function(date) { moment().locale('pt-br'); return moment(date, "D_M_YYYY").format('ddd'); } it returns name of weekday in english but need portuguese weekday…
Nisarg
  • 3,024
  • 5
  • 32
  • 54
4
votes
1 answer

Angular Material datepicker + moment, serializing the moment objects for backend?

I have a date picker using the moment adapter with the locale, all is ok with the dates but I can't get convert them on the backend. I'm getting it from the form using formGroup.value Before sending it to the backend (via angular firebase) it looks…
1
2 3
13 14