Home > front end >  Js to calculate two dates vary the number of days to 30 days into a week of natural transformation n
Js to calculate two dates vary the number of days to 30 days into a week of natural transformation n

Time:10-13

Choose a time within 30 days, according to the days of dimension, b exceeds 30 days, according to the Zhou Weidu show, natural weeks, show specific time interval, example: the first week of July (1 ~ 7), the second week of July (8 ~ 14) third week (July 15 ~ 22) the fourth week (July 23 ~ 30) fifth week choose three days, the show (August 1 ~ 3), c, beyond one year, according to the month dimensions shown

CodePudding user response:

 
Var str1="2019/11/01";
Var str2="2020/01/09";
Var time=new Date (str2.) getTime () - the new Date (str1). GetTime ();
Var date=math.h ceil (time/(24 * 60 * 60 * 1000));
If (date<30)={
Alert (date + the "day");
} else if (date<{
=365)Alert (math.h ceil (date/7) + "weeks");
} else {
Alert (math.h ceil (date/30) + "month");
}

CodePudding user response:

Ok I try, thanks
  • Related