Git Product home page Git Product logo

angular-moment's Introduction

angular-moment

Wrapper for moment.js

Bower Install

"dependencies": {
   "momentjs": "~2.6.0",
   "angular-moment": "jcamelis/angular-moment"
}

Filters

moment("2014-11-24T05:45:00Z").add('days', 5).calendar()
<p>{{ "2014-11-24T05:45:00Z" | momentAdd:'days':5 | momentCalendar }}</p>

output: 11/29/2014

  • calendar
moment("2014-11-24T05:45:00Z").calendar();
<p>{{ "2014-11-24T05:45:00Z" | momentCalendar }}</p>

output: 11/24/2014

  • day
moment("2014-11-24T05:45:00Z").day("2014-11-29T05:45:00Z");
<p>{{"2014-12-27T05:45:00Z" | momentDay}}</p>

output: 6

  • dayOfYear
moment("2014-02-24T05:45:00Z").dayOfYear();
<p>{{"2014-02-24T05:45:00Z" | momentDayOfYear}}</p>

output: 55

  • diff
moment("2014-11-24T05:45:00Z").diff("2014-11-29T05:45:00Z");
<p>{{"2014-11-24T05:45:00Z" | momentDiff:"2014-11-29T05:45:00Z"}}</p>

output: -432000000

  • daysInMonth
moment("2012-02").daysInMonth();
<p>{{"2012-02" | momentDaysInMonth}}</p>

output: 29

  • enOf
moment().endOf("week");
<p>{{"week" | momentEndOf}}</p>

output: "2014-05-25T02:59:59.999Z"

  • toJSON
moment().toJSON();
<p>{{"2014-11-24" | momentToJSON}}</p>

output: 2014-11-24T03:00:00.000Z

  • format
moment().format("dddd, MMMM Do YYYY, h:mm:ss a");
<p>{{"2014-11-24T05:45:00Z" | momentFormat:"dddd, MMMM Do YYYY, h:mm:ss a"}}</p>

output: Monday, November 24th 2014, 2:45:00 am from moment docs

  • from
moment("2014-05-21T15:08:00Z").from("2014-04-21T15:08:00Z");
<p>{{"2014-05-21T15:08:00Z" | momentFrom:"2014-04-21T15:08:00Z"}}</p>

output: in a month

  • fromNow
moment("2014-05-20T09:45:00Z").fromNow();
<p moment-interval="1000">{{"2014-05-21T14:25:00Z" | momentFromNow}}</p>

output: a few seconds ago

  • get
moment("2014-05-21T15:08:00Z").get();
<p >{{"2011-05-21T15:08:00Z" | momentGet:'year'}}</p>

output: 2011

  • hour
moment().hour(Number);
<p >{{"2011-05-21T15:08:00Z" | momentHour:10}}</p>

output: "2011-05-21T05:08:00.000Z"

  • utc
moment("2015-01-29T00:00:00Z").utc().format("DD MM YYYY");
<p>{{"2015-01-29T00:00:00Z" | momentUtc | momentFormat: "D MMM, HH:mm"}}</p>

output: 29 Jan, 00:00

  • zone
moment(1404462900000).zone("-5").format("D MMM, HH:mm");
<p>{{1404462900000 | momentZone:-5 | momentFormat: "D MMM, HH:mm"}}</p>

output: "4 Jul, 08:35"

Directives

  • momentInterval
<p moment-interval="1000">{{"2014-05-21T14:25:00Z" | momentFromNow}}</p>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.