简体   繁体   中英

Connect moment-range with sails backend

I want to get date range between start_time and end_time.

 var newrange = sails.moment.range(start_time, end_time);

But it says,

 TypeError: sails.moment.range is not a function

Try setting up the imports like below and then run the function:

const moment = require("moment");
const momentRange = require("moment-range");
momentRange.extendMoment(moment); 

var newrange = moment.range(start_time, end_time);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM