js实现当月首末日期

<script type="text/javascript">
function show(){
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1;
var lastDay = new Date(year, month, 0); //次月第一天的前一天
alert(
"当前月第一天:" + year + "-" + month + "-01" + "\n" +
"当前月最后一天:" + year + "-" + month + "-" + lastDay.getDate()
);
}
</script>
<input type="button" onclick="show()" value="Show"/>
posted @ 2012-02-01 13:57  布洛瓷  阅读(482)  评论(0编辑  收藏  举报