Back to Home

Moment.js: easy date handling

javascript · javascript date · javascript library

Moment.js: easy date handling


    Moment.js is a great JavaScript date library. Examples under the cut.

    var now = moment();
    moment.lang('ru');
    console.log(now.format('dddd, MMMM DD YYYY, h:mm:ss'));
    // вторник, ноябрь 15 2011, 3:31:03
    


    var halloween = moment([2011, 9, 31]); // October 31st
    moment.lang('ru');
    console.log(halloween.fromNow());
    // 16 дней назад
    


    var now = moment().add('days', 9);
    moment.lang('ru');
    console.log(now.format('dddd, MMMM DD YYYY'));
    // четверг, ноябрь 24 2011
    


    var now = moment();
    moment.lang('ru');
    console.log(now.format('LLLL'));
    // вторник, 15 ноябрь 2011 15:27
    


    Well, actually the links:
    Offsite | Documentation | github

    PS In my opinion the most adequate for work with dates. It remains only to finish the normal support of the Russian language.

    Read Next