查找当前日期所在周的周一的日期

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')

 

你可能感兴趣的:(JavaScript,Rails)