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

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

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

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

2024.12.11 | 1353閱讀 | 0條評(píng)論 | 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);



打印格式為年月日時(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)論

临沂市| 赣榆县| 西吉县| 四子王旗| 保康县| 西畴县| 杭锦旗| 西平县| 远安县| 博兴县| 天气| 丰都县| 耿马| 武平县| 和龙市| 泊头市| 婺源县| 衡山县| 漯河市| 集安市| 景谷| 兰西县| 敖汉旗| 安乡县| 武安市| 磴口县| 永德县| 太康县| 泉州市| 久治县| 张家口市| 永登县| 金乡县| 凤冈县| 长海县| 罗山县| 丰顺县| 札达县| 双峰县| 安顺市| 确山县|