2017年8月24日周四,如何查询上周同一天的日期?

更新于
2026-09-29 11:49:59
2阅读来源:SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计145个文字,预计阅读时间需要1分钟。

2017年8月24日周四,如何查询上周同一天的日期?

javascriptfunction getPrevWeek() { let date=new Date(); let year=date.getFullYear(); let month=date.getMonth() + 1; let dayWeek=date.getDay(); let dayMonth=date.getDate(); let json={ 1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30 };}

2017年8月24日周四,如何查询上周同一天的日期?

gistfile1.txt

function getPrevWeek () { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; var dayWeek = date.getDay(); var dayMonth = date.getDate(); var json = { 1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31 }; if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) { // 闰年 2 月份 有 29 天 json[2] = 29; } if (dayMonth > 7) { return year + '-' + month + '-' + (dayMonth - 7); } // 上周的日期在上个月的情况 return year + '-' + (month - 1) + '-' + (json[month - 1] + dayMonth - 7) }

本文共计145个文字,预计阅读时间需要1分钟。

2017年8月24日周四,如何查询上周同一天的日期?

javascriptfunction getPrevWeek() { let date=new Date(); let year=date.getFullYear(); let month=date.getMonth() + 1; let dayWeek=date.getDay(); let dayMonth=date.getDate(); let json={ 1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30 };}

2017年8月24日周四,如何查询上周同一天的日期?

gistfile1.txt

function getPrevWeek () { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; var dayWeek = date.getDay(); var dayMonth = date.getDate(); var json = { 1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31 }; if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) { // 闰年 2 月份 有 29 天 json[2] = 29; } if (dayMonth > 7) { return year + '-' + month + '-' + (dayMonth - 7); } // 上周的日期在上个月的情况 return year + '-' + (month - 1) + '-' + (json[month - 1] + dayMonth - 7) }