js获取当前日期,格式为YYYY-MM-DD
//获取当前时间,格式YYYY-MM-DD
function getNowFormatDate() {
var date = new Date();
var seperator1 = “-“;
var year = date.getFullYear();
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = “0” + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = “0” + strDate;
}
var currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate;
}
借鉴于:https://www.cnblogs.com/wxdblog/p/6888240.html
JS日期格式化
本文介绍了一个简单的JavaScript函数,用于获取并格式化当前日期为YYYY-MM-DD格式。此方法适用于需要在网页应用中快速获取标准日期格式的情况。
6万+

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



