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

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

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

js在當(dāng)前日期添加天、周、月、年

2024.12.11 | 1562閱讀 | 0條評(píng)論 | javascript


//創(chuàng)建date

var nowDate = new Date();


//添加天數(shù)

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


//添加周 添加周用添加天的方式,來(lái)添加七天,即為一周

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


//添加月數(shù)

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


//添加年數(shù)

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



打印格式為年月日時(shí)分秒

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ā)表評(píng)論

庄河市| 宜兰市| 南岸区| 九江县| 乡宁县| 北辰区| 河北省| 都江堰市| 漳浦县| 菏泽市| 栖霞市| 三江| 当涂县| 肃宁县| 金寨县| 永定县| 黑龙江省| 拜城县| 鄂尔多斯市| 民县| 施秉县| 沽源县| 兰州市| 大连市| 临江市| 甘肃省| 东宁县| 秀山| 土默特右旗| 邯郸市| 邯郸市| 六安市| 恭城| 封丘县| 沐川县| 贵德县| 浙江省| 南昌县| 专栏| 城口县| 都匀市|