如何使用jquery获取当前星期的开始日期和结束日期?
例如,今天是03/18/2019,本周的开始日期是(03/18/2019),结束日期是(24/18/2019),我见过LINK,但我想用最少的代码来表达此功能,请注意,一周从星期一开始,在星期日结束
答案 0 :(得分:1)
这将为您工作:
<script>
var curr = new Date;
var firstday = new Date(curr.setDate(curr.getDate())).toUTCString();
var lastday = new Date(curr.setDate((curr.getDate())+6)).toUTCString();
</script>
答案 1 :(得分:-1)
var today = new Date;
var first_date = new Date(today.setDate(today.getDate())).toUTCString();
var last_date = new Date(today.setDate(today.getDate() + 6)).toUTCString();
console.log('First Day :', first_date);
console.log('Last Day :', last_date);