獲取當前日期以及三天後的日期

2022-05-29 13:24:10 字數 926 閱讀 2850

var date=new date();//獲取當前時間

var year=date.getfullyear();//獲取當前年份

var month=date.getmonth()+1;//獲取當前月

var day=date.getdate();//獲取當前日

var nowtime=newday+'.'+month+'.'+day;//當前日期

console.log(nowtime);列印輸出就是當前日期啦~

var runyear=[31,29,31,30,31,30,31,31,30,31,30,31];//獲取閏年所有月份資訊

var pingyear = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];//獲取平年所有月份資訊

var newday=day;//定義新日期變數

var newmonth=month;//定義新日期變數

var newyear=year;//定義新日期變數

const days=3;//代表3天後,如果要求四天後,值可直接設為4,依次類推

if (year % 4 == 0 && year % 100 != 0)

else if (runyear[month-1] - newday < 2&&newmonth!=12)

else

}else

else if (pingyear[month-1] - newday < 2 && newmonth != 12)

else

}var willtime=newyear+'.'+newmonth+'.'+newday;//後三天日期

console.log(willtime);//列印輸出就是三天後的日期啦~

js 獲取當前日期的後30天

開始時間 設定為今天 thu aug 01 2019 15 00 01 gmt 0800 中國標準時間 var startdate new date console.log startdate 初始化結束時間 var enddate new date console.log enddate getd...

獲取當前日期

js獲取當前時間 獲取當前時間戳 function getnowdate 時間戳轉所需樣式 timechange.js long型別時間轉換為日期 擴充套件date的format方法 date.prototype.format function format if y test format for...

php 獲取前5天的日期 php獲取當前日期時間

函式 date string format int timestamp 可以格式化日期 時間,引數format是格式化字串,最常用的值如下 y 4位數字完整表示的年份 y 2位數字表示的年份 m 數字表示的月份 m 三個字母縮寫表示的月份 d 月份中的第幾天 d 星期中的第幾天 h 小時,12 小時...