欧美一级色视频,簧片在线免费看,美日韩在线,成人观看网站a,亚洲欧美在线一区二区,欧美操穴,欧美综合专区

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

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

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

2024.12.11 | 1632閱讀 | 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ā)表評論

家居| 交城县| 桦川县| 山丹县| 天气| 大宁县| 怀集县| 景宁| 梓潼县| 淅川县| 个旧市| 分宜县| 独山县| 淳安县| 丰都县| 阿城市| 依兰县| 类乌齐县| 勃利县| 兰考县| 临沭县| 公主岭市| 定安县| 鸡东县| 余江县| 平塘县| 高阳县| 许昌市| 楚雄市| 武陟县| 白河县| 九龙县| 泰宁县| 成安县| 赣榆县| 古浪县| 宽甸| 民权县| 沈阳市| 马公市| 全南县|