---
title: "js 获取 月 的 周数"
author: "onlyor"
date: "2013-04-17T15:41:31Z"
tags: []
categories: ["Web前端"]
slug: "js"
draft: false
lastmod: "2013-04-17T15:41:31Z"
id: 1848930
url: "https://onlyor.iteye.com/blog/1848930"
---

```
<script>


function getMonthWeek (a, b, c) {
  var date = new Date(a, parseInt(b) - 1, c), w = date.getDay(), d = date.getDate();   
  return Math.ceil((d+7-w)/7);   
};   

var last=new Date(2013,9, 0);//获取当前月最后一天时间  
var y = last.getFullYear();  
var m = last.getMonth()+1;  
var d = last.getDate();  
document.write( "周数"+ getMonthWeek(y, m, d)+' 年 ' +y+ ' 月 '+m+' 日 ' + d ); 
</script>
```