如何获取2017年8月前一个月的日期,即'2017-07'?

更新于
2026-09-29 11:05:57
0阅读来源:SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

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

如何获取2017年8月前一个月的日期,即'2017-07'?

javascriptfunction getPrevMonth() { var date=new Date(); var year=date.getFullYear(); var month=date.getMonth() + 1; if (month===1) { return (year - 1) + '-12'; } else if (month > 10) { return year + '-' + (month - 1); }}

如何获取2017年8月前一个月的日期,即'2017-07'?

gistfile1.txt

function getPrevMonth () { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; if (month === 1) { return (year - 1) + '-' + 12; } else if (month > 10) { return year + '-' + (month - 1); } else { return year + '-' + '0' + (month - 1); } }

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

如何获取2017年8月前一个月的日期,即'2017-07'?

javascriptfunction getPrevMonth() { var date=new Date(); var year=date.getFullYear(); var month=date.getMonth() + 1; if (month===1) { return (year - 1) + '-12'; } else if (month > 10) { return year + '-' + (month - 1); }}

如何获取2017年8月前一个月的日期,即'2017-07'?

gistfile1.txt

function getPrevMonth () { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; if (month === 1) { return (year - 1) + '-' + 12; } else if (month > 10) { return year + '-' + (month - 1); } else { return year + '-' + '0' + (month - 1); } }