WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Moment.js

Mathias Rangel Wulff edited this page Jun 13, 2015 · 2 revisions

Formatting Dates with Moment.js

You can use Moment.js library to format dates:

    moment.locale('fr'); // Set French locale for moment.js
    alasql.fn.moment = moment; // Set moment() function available to AlaSQL

    var data = [{d:new Date()},{d:"2013-02-14"}];
    var res = alasql('SELECT moment(d)->[add](1, "days")->calendar() as [When?]\
            FROM ?',[data]);

See the full example in jsFiddle

Clone this wiki locally