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

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

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

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

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

土默特左旗| 湖南省| 西宁市| 安国市| 贺兰县| 西畴县| 海门市| 亳州市| 宜都市| 静宁县| 巴东县| 新竹县| 平定县| 当涂县| 北票市| 琼结县| 钦州市| 平遥县| 太谷县| 湾仔区| 台北县| 肥城市| 昌吉市| 南开区| 铅山县| 东乡县| 含山县| 年辖:市辖区| 竹溪县| 土默特左旗| 合水县| 渭源县| 湟中县| 邳州市| 稻城县| 长沙市| 新宁县| 阿勒泰市| 崇明县| 崇义县| 右玉县|