/ *ヴァール=新しい新MyDateに該当日付();
myDate.getYear(); //取得現在の年(2)
myDate.getFullYear(); //取得通期(4、1970 - ????)
MyDateに該当。 getMonth(); //現在の月を取得(0-11,0代わっ月)
myDate.getDate(); //現在の日付を取得します(1-31)
myDate.getDay(); //現在の週のXを取得します(0-日曜日6,0)
myDate.getTime(); //開始1970年1月1日からのミリ秒の現在の時間(数を取得)
myDate.getHours(); //現在の数を取得する(0-23)時間
myDate.getMinutes(); //現在の数を取得する(0-59)分
myDate.getSeconds(); //現在の秒数(0〜59)を取得
myDate.getMilliseconds(); //取得し、現在のミリ秒(0〜999)
(myDate.toLocaleDateStringを) ; //現在の日付を取得
VaRのmytimeは= myDate.toLocaleTimeString(); //現在時刻が取得
myDate.toLocaleString(); //日付と時刻を取得する* /
/ **
*現在の3ヶ月の月の最初の日の前に取得します
* /
機能getCurrentMonthThree(){
VAR日付=新しいDate(); // 現在のタイム
VAR currentYear = date.getFullYear(); //取得通期の
VAR currentMonth = date.getMonth(); //現在の月(0-11,0代わっ1月)
VaRのthreeMonth、現在の月の//最初の3ヶ月間
のvar threeMonthFirstDay、3ヶ月、現在の月の@の最初の日の前に
(currentMonth <3。){IF
currentYear - = 1; //保存1年
threeMonth = currentMonth + 12 - 3; //現在の月の三ヶ月最初
}他{
threeMonth currentMonth = - 3; //現在の月の最初の3ヶ月
}
threeMonthFirstDay新しい新しい=日(currentYear、threeMonth ,. 1); //現在の月の最初の日の前3ヶ月
のリターンthreeMonthFirstDay;
}
/ **
*月の最後の日前に、現在の月を取得します
* /
関数getCurrentMonthOne(){
VAR =新しい新しいDATE日付(); //現在のタイム
VAR currentYear = date.getFullYear(); //通年の取得
VAR currentMonth = date.getMonth(); //現在の月を(0-11,0代わっ1月)
VAR oneMonth; //現在の月の前の月
のvar oneMonthFirstDay; //月現在の月の最初の日の前
のvar monthFirstDay =新しい日付(currentYear、 currentMonth、1); // 現在の月の最初の日
のvar oneDay = 1000年* 60 * 60 * 24; //日ミリ秒
oneMonthFirstDay =新しいDate(monthFirstDay-oneDay ); 現在の月マイナス1日の//初日
のリターンoneMonthFirstDay;
}
/ **
*現在の月の最後の日を取得します
* /
機能getCurrentMonthLast(){
VAR =新しい新しいDATE日付(); //現在のタイム
VAR currentYear = date.getFullYear(); //通年取得
VAR currentMonth = date.getMonth(); //現在の月(1月0-11,0表す)
VaRのnextMonthを; //月の
VaRのnextMonthFirstDay、月の//最初の日
であれば(currentMonth <11){ //ない先月
nextMonth = ++ currentMonth; //月追加1
}他{//先月
currentYear + = 1; //年追加1。
nextMonth = 0; //月は最初の月である
}
nextMonthFirstDay =新しい日付(currentYear、nextMonth、1 ); // 月の最初の日
のvar oneDay = 1000 * 60 * 60 * 24; //ミリ秒数日
新しい日付(nextMonthFirstDay-oneDay)を返す ; // 月マイナス1日の最初の日
}
jsが現在の月の最終日を取得し、jsの前月の最終日を取得し、jsの3ヶ月前に、現在の月の最初の日に乗ります
おすすめ
転載: blog.csdn.net/qq_36161345/article/details/92609642
おすすめ
ランキング