本文介绍了如何使用moment.js添加几天(不包括周末)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从当前日期起两天设置默认的跟踪日期,该日期目前有效:

I'm setting a default follow-up date two days from current date, which currently works:

const Notify = moment().add(2, 'days').toDate();

但是,我想排除周末.因此,我安装了 WeekDay 时刻,但似乎无法将其添加到当前日期中.该文档要求:

However, I would like to exclude weekends. So I installed moment WeekDay, but I can't seem to get it to work with adding days to the current date. The documentation calls for:

moment().weekday(0)

但是我无法在两天前完成添加.有任何想法吗?

But I can't get that to work with adding in two days forward. Any ideas?

推荐答案

尝试:时刻-营业日

它应该可以帮助您.

示例:

var momentBusinessDays = require("moment-business-days")

momentBusinessDays('20-09-2018', 'DD-MM-YYYY').businessAdd(3)._d

结果:

Tue Sep 25 2018 00:00:00 GMT+0530 (IST)

这篇关于如何使用moment.js添加几天(不包括周末)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 20:18