国产精品7777777,国产亚洲第一页,亚洲激情网,三级黄色在线免费观看,91男生福利,91男生福利,亚洲天堂福利

龍巖易富通網(wǎng)絡(luò)科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

js在當前日期添加天、周、月、年

2024.12.11 | 1272閱讀 | 0條評論 | javascript


//創(chuàng)建date

var nowDate = new Date();


//添加天數(shù)

nowDate.setDate(nowDate.getDate() + 1);


//添加周 添加周用添加天的方式,來添加七天,即為一周

nowDate.setDate(nowDate.getDate() + 7);


//添加月數(shù)

nowDate.setMonth(nowDate.getMonth() + 1);


//添加年數(shù)

nowDate.setYear(nowDate.getFullYear() + 1);



打印格式為年月日時分秒

const year = nowDate.getFullYear();

const month = (nowDate.getMonth() + 1).toString().padStart(2, '0');

const day = nowDate.getDate().toString().padStart(2, '0');

const hours = nowDate.getHours().toString().padStart(2, '0');

const minutes = nowDate.getMinutes().toString().padStart(2, '0');

const seconds = nowDate.getSeconds().toString().padStart(2, '0');

console.log(`${year}-${month}-${day} ${hours}:${minutes}:${seconds}`);


贊 (

發(fā)表評論

比如县| 萨嘎县| 集安市| 凤阳县| 从化市| 兰西县| 澎湖县| 安泽县| 宜兴市| 定边县| 沙坪坝区| 澄江县| 安国市| 太谷县| 盖州市| 东光县| 满城县| 布拖县| 潼关县| 秦皇岛市| 三门峡市| 凤城市| 通渭县| 远安县| 河池市| 宣武区| 临桂县| 乐业县| 德安县| 德庆县| 勃利县| 泽库县| 义乌市| 浙江省| 道真| 明星| 遂宁市| 弥勒县| 阜宁县| 旅游| 拜泉县|