javascript - Populate Formatted dates form select menu -


hi stackoverflow community.

on application have select option user selects date option , based on option populate dates accordingly.

however date or week must start on sunday , end on saturday. months selection start first. current month count of august, next 2 months start sept end of oct.

here wrote far

jsbin

if have

 moments js 
solution welcome it

thank you

i've learn vagaries of js date(), put fiddle.

it uses standard js data manipulation through series of functions you'll able figure out easily.

what i'm not sure of mean "month" "two months" , "six months" - i've assumed month 4 week period, , not calendar month.

edit: re-read text , i'll work on definition of month.

here js functions:

function adddays(anydate1, daystoadd) {   var mydaystoadd = daystoadd;   var daysadded = anydate1.getdate() + mydaystoadd;   return new date( anydate1.setdate( daysadded ) ); }  function startofweek( anydate ) {   localdate = anydate;   daydifference = 0;   daydifference = localdate.getdate() - numericdayofweek( localdate );   return new date( localdate.setdate( daydifference ) );   }  function textdayofweek(mydate) {   var dayarray = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];   return dayarray[ numericdayofweek(mydate) ]; }  function numericdayofweek( anydate7 ) {   var localdate = anydate7;   return localdate.getday(); }  function todayfull()  {   return new date(); }  function todayshort( mydate3 ) {  localdate = mydate3;  thedate =  (localdate.getmonth() + 1) + '/' +    localdate.getdate() + '/' +    localdate.getfullyear();   return thedate; } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -