javascript - Return dates from previous weekend -


I'm trying to return dates from javascript Monday to Monday. Now if the present day is between Friday and Monday, then I want to return from today to Friday. Even so far like I have, but I'm missing something.

  function getPrevFriday () {var Friday = 5; Var current time = new date (); Var Month = Current Time.Getmonth () + 1; Var day = currentTime.getDay (); Var date = currentTime.getDate (); Var Year = Current TimeGetFullear (); Var Last Friday = Date - (Friday + (7 days))% 7 + 1; Return month + "/" + Last Friday + "/" + year; }; Function getPrevMonday () {var Friday = 5; Var current time = new date (); Var Month = Current Time.Getmonth () + 1; Var day = currentTime.getDay (); Var date = currentTime.getDate (); Var Year = Current TimeGetFullear (); Var Last Friday = Date - (Friday + (7 days))% 7 + 4; Return month + "/" + Last Friday + "/" + year; }; Function Returns Preview () {var currentTime = New Date (); Var Month = Current Time.Getmonth () + 1; Var day = currentTime.getDay (); Var Year = Current TimeGetFullear (); Function returns (today) (return month + "/" + day + "/" + year;} $ ('# to, .startdate'). Val (getPrevFriday ()); if (days <5 & amp; ; & Amp;; Day & gt; {} ('# to, .endDate') Val (getPrevMonday ()); $ ('Date-from') .HTML (getPrevFriday () + '& amp; nbsp ; - & lt; br & gt; & amp; nbsp; + getPrev Monday ());} and {$ ('# to, .endDate'). Val (refunds); $ ('Date-from') .HTML (getPrevFriday (+) & amp; nbsp; - & lt; br & gt; & amp; nbsp; '+ Return Today ());}};    

Something like this:

  var today = new date (); var noOfDays = 0; // Today, on Friday, If Saturday or Sunday (today .getDay ()> = 5) {noOfDays = today.getDay () - 5;} Else {// Otherwise Noofida = (2 + aa) .getDay ());} Var days = []; for (var i = 0; i <4; i ++) {days.push (new date (today.gatefulair), today.gatemonth () , Today .getDate () - No Offshish + i))} Console.log (day) // Friday - Monday    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -