【问题标题】:Find the first and last day of month based on the month number in Angular根据 Angular 中的月份编号查找月份的第一天和最后一天
【发布时间】:2020-06-12 09:33:00
【问题描述】:

我有一个包含所有月份和月份数的数组,如下所示:

  months = [
    { name: 'JANUARY', id: 0 },
    { name: 'FEBRUARY', id: 1 },
    { name: 'MARCH', id: 2 }
   ......
]

【问题讨论】:

标签: html angular momentjs


【解决方案1】:

我认为这篇类似的帖子(分享下面的链接)将帮助您实现目标。概念保持不变。

链接 Get first and last date of current month with JavaScript or jQuery

【讨论】:

    【解决方案2】:
    startAndEndOfSelectedMonth() {
        let year = new Date().getFullYear();
        let startDate = moment([year, this.month - 1]);
    
        let endDate = moment(startDate).endOf('month');
    
        return { start: startDate, end: endDate };
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      • 2014-11-21
      • 1970-01-01
      • 1970-01-01
      • 2011-11-24
      • 2018-05-28
      • 1970-01-01
      相关资源
      最近更新 更多