99麻豆久久久国产免费福利精品,国产精品成人国产乱,玖玖操,手机看片169,国产精彩视频在线观看,午夜亚洲福利视频,国产伦乱视频

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

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

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

2024.12.11 | 1364閱讀 | 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)論

岳普湖县| 芷江| 河北省| 青川县| 从化市| 明水县| 临沭县| 景德镇市| 张掖市| 平武县| 苏尼特右旗| 体育| 阳春市| 星子县| 成安县| 府谷县| 盐亭县| 巢湖市| 长泰县| 舟山市| 平阳县| 北安市| 奉节县| 宁城县| 会东县| 开平市| 甘德县| 鞍山市| 凤阳县| 新田县| 监利县| 黔东| 平湖市| 大方县| 兴仁县| 镇原县| 绥滨县| 昔阳县| 桓仁| 略阳县| 三台县|