从一个月开始
我希望从本月开始的整个天数。例如,本月(2022年4月)有
const monthDays = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 , 30 ]
天
Array.from(Array(moment('2022-04').daysInMonth()).keys())
30
// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
的第一天或第一个月,但是如何从上面的示例中获得想要的结果,
因此,如果我获取当前月份,则基本上mist
将自动生成此数组。我们该如何实现?
I wish to have all the days from the current month in an array. For example this month (April 2022) has 30 days so I wish to have an array of integers like so:
const monthDays = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 , 30 ]
My attempt :
Array.from(Array(moment('2022-04').daysInMonth()).keys())
And the output is :
// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
I have and idea how moment works and 0
is always the first day or the first month , but how can i achieve the result that i want from the example above
So basically moment
will generate automatically this array if I fetch the current month. How can we achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
daysInmonth()
获取天数1
到步骤3的结果的数组daysInMonth()
to get the number of days1
to the result of step 3