Skip to content

Instantly share code, notes, and snippets.

@cmmartin
Last active July 31, 2019 09:01
Show Gist options
  • Select an option

  • Save cmmartin/341b017194bac09ffa1a to your computer and use it in GitHub Desktop.

Select an option

Save cmmartin/341b017194bac09ffa1a to your computer and use it in GitHub Desktop.

Revisions

  1. cmmartin revised this gist Jun 19, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion moment-filter.js
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@
    // {{ someDate | moment: 'utc' | moment: 'format': 'MMM DD, YYYY' }}

    angular.module('myModule').filter('moment', function () {
    return function (input, momentFn /*, param1, param2, etc... */) {
    return function (input, momentFn /*, param1, param2, ...param n */) {
    var args = Array.prototype.slice.call(arguments, 2),
    momentObj = moment(input);
    return momentObj[momentFn].apply(momentObj, args);
  2. cmmartin revised this gist Jun 15, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion moment-filter.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    // REQUIRES:
    // moment.js - https://github.com/moment/momentjs.com
    // moment.js - http://momentjs.com/

    // USAGE:
    // {{ someDate | moment: [any moment function] : [param1] : [param2] : [param n]
  3. cmmartin revised this gist Nov 12, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion moment-filter.js
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@

    // To call multiple moment functions, you can chain them.
    // For example, this converts to UTC and then formats...
    // {{ someDate | moment: 'utc' | moment: 'MMM DD, YYYY' }}
    // {{ someDate | moment: 'utc' | moment: 'format': 'MMM DD, YYYY' }}

    angular.module('myModule').filter('moment', function () {
    return function (input, momentFn /*, param1, param2, etc... */) {
  4. cmmartin revised this gist Nov 12, 2014. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion moment-filter.js
    Original file line number Diff line number Diff line change
    @@ -5,9 +5,12 @@
    // {{ someDate | moment: [any moment function] : [param1] : [param2] : [param n]

    // EXAMPLES:
    // {{ someDate | moment: 'format': 'MMM, DD, YYYY' }}
    // {{ someDate | moment: 'format': 'MMM DD, YYYY' }}
    // {{ someDate | moment: 'fromNow' }}

    // To call multiple moment functions, you can chain them.
    // For example, this converts to UTC and then formats...
    // {{ someDate | moment: 'utc' | moment: 'MMM DD, YYYY' }}

    angular.module('myModule').filter('moment', function () {
    return function (input, momentFn /*, param1, param2, etc... */) {
  5. cmmartin created this gist Nov 11, 2014.
    18 changes: 18 additions & 0 deletions moment-filter.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    // REQUIRES:
    // moment.js - https://github.com/moment/momentjs.com

    // USAGE:
    // {{ someDate | moment: [any moment function] : [param1] : [param2] : [param n]

    // EXAMPLES:
    // {{ someDate | moment: 'format': 'MMM, DD, YYYY' }}
    // {{ someDate | moment: 'fromNow' }}


    angular.module('myModule').filter('moment', function () {
    return function (input, momentFn /*, param1, param2, etc... */) {
    var args = Array.prototype.slice.call(arguments, 2),
    momentObj = moment(input);
    return momentObj[momentFn].apply(momentObj, args);
    };
    });