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