当前位置:网站首页>JS函数获取本月的第一天和最后一天
JS函数获取本月的第一天和最后一天
2022-08-03 07:20:00 【南黎1】
本月第一天:
function getLastDay(){
var y = new Date().getFullYear(); //获取年份
var m = new Date().getMonth() + 1; //获取月份
var d = '01'
m = m < 10 ? '0' + m : m; //月份补 0
return [y,m,d].join("-")
}
本月最后一天:
function getLastDay(){
var y = new Date().getFullYear(); //获取年份
var m = new Date().getMonth() + 1; //获取月份
var d = new Date(y, m, 0).getDate(); //获取当月最后一日
m = m < 10 ? '0' + m : m; //月份补 0
d = d < 10 ? '0' + d : d; //日数补 0
return [y,m,d].join("-")
}
注:源码来自于网络
边栏推荐
猜你喜欢
随机推荐
Poke the myth of Web3?Poke the iron plate.
测试用例设计方法之因果图详解
第六章:存储系统
CDGA|如何加强数字政府建设?
static数据成员
tmp
华为设备BFD配置命令
剑指offer专项突击版第18天
2022年 SQL 优化大全总结详解
酷雷曼上新6大功能,全景营销持续加码
jolt语法
【着色器实现HandDrawn简笔画抖动效果_Shader效果第十二篇】
华为设备配置BFD与接口联动(触发与BFD联动的接口物理状态变为Down)
华为设备配置BFD单跳检测二层链路
- display image API OpenCV 】 【 imshow () to a depth (data type) at different image processing methods
面试介绍项目经验(转)
Shell运维开发基础(一)
How to choose a reliable and formal training institution for the exam in September?
boot - SSE
华为设备配置BFD多跳检测