查找当前日期所在周的周一的日期
程序员文章站
2022-07-15 12:52:35
...
JavaScript:
- var now = new Date();
- var monday = now;
- monday.setDate(now.getDate() - now.getDay() + 1);
- monday_date = monday.getFullYear() + "-" + monday.getMonth() + "-" + monday.getDate();
- now = new Date();
- var sunday = new Date();
- sunday.setDate(now.getDate() - now.getDay() + 7);
- monday_date = sunday.getFullYear() + "-" + sunday.getMonth() + "-" + sunday.getDate();
Rails:
- monday_date = Date.today.beginning_of_week.strftime('%d/%m/%Y')
下一篇: 查找当前日期所在周的周一的日期