查找当前日期所在周的周一的日期
程序员文章站
2022-07-15 12:52:29
...
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')
上一篇: 查找当前日期所在周的周一的日期
下一篇: Draper的用法