function getNowMonthDate() {
var date = new Date();
var year = date.getFullYear() + "";
var month = (date.getMonth() + 1) + "";
// 本月第一天日期
var begin = year + "-" + month + "-01 00:00:00"
// 本月最后一天日期
var lastDateOfCurrentMonth = new Date(year,month,0);
var end = year + "-" + month + "-" + lastDateOfCurrentMonth.getDate() + " 59:59:59";
return begin + "-" +end;
}
js获取当月第一天和最后一天
最新推荐文章于 2024-07-08 10:18:42 发布
本文介绍了一个JavaScript函数,用于获取当前月份的第一天和最后一天的日期,格式为'年-月-日小时:分钟:秒',适用于各种日期相关应用程序的开发。
8278

被折叠的 条评论
为什么被折叠?



