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

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

龍巖小程序開(kāi)發(fā),龍巖分銷(xiāo)系統

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

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


//創(chuàng )建date

var nowDate = new Date();


//添加天數

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


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

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


//添加月數

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


//添加年數

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ā)表評論

永丰县| 若羌县| 台江县| 政和县| 新巴尔虎右旗| 盐山县| 额尔古纳市| 新田县| 修武县| 昌黎县| 察哈| 陵川县| 鹰潭市| 南开区| 高密市| 五莲县| 精河县| 浙江省| 泾阳县| 兴化市| 黔东| 静宁县| 贺州市| 靖边县| 攀枝花市| 漯河市| 钦州市| 阳山县| 广宗县| 天津市| 大邑县| 邢台县| 怀宁县| 孟连| 新晃| 灵石县| 蒙自县| 鄂尔多斯市| 大冶市| 石门县| 新营市|