Get Today Date & Next 2 Days - Display In Select Option January 29, 2024 Post a Comment I want to display date in below options. Have to get today date and display next 2 days date in select component. Plugin used - Selectize HTML: ), monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; for(var day = 0; day < 3; day++) { var date = newDate(); date.setDate(date.getDate() + day); dateRange.options[dateRange.options.length] = newOption([date.getDate(), monthNames[date.getMonth()], date.getFullYear()].join(' '), date.toISOString()); }Copy<selectid="date-range"></select>CopySolution 2: For this you also can use moment-transform. it's really easy to achieve any date and time with one line of code, for what you want it should be like this : moment().transform("YYYY-MM-+100:00:00.000") //This display the next day ( Tomorrow )moment().transform("YYYY-MM-+200:00:00.000") //This display the day after tommorowCopythe key is +1 & +2 and so on. also you can show yesterday date if you use -1 like : moment().transform("YYYY-MM--100:00:00.000") //This display the Yesterday dateCopySolution 3: Here you go with a solution https://jsfiddle.net/pp6ko79g/var today = newDate(); var month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] for(var i=0; i<3; i++){ var tDate = newDate(); tDate.setDate(today.getDate()+i); var optionDate = tDate.getDate() + " " + month[tDate.getMonth()] + " " + tDate.getFullYear(); $('select').append('<option>' + optionDate + '</option'); }Copy<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><select></select>CopySolution 4: var today = newDate(); var tomorrow = newDate(); var afterTomorrow = newDate(); tomorrow.setDate(today.getDate()+1); afterTomorrow.setDate(today.getDate()+2); console.log(tomorrow, afterTomorrow);Copyyou can package and format the result, it will be what you expect. Share Post a Comment for "Get Today Date & Next 2 Days - Display In Select Option" Top Question Firefox 5 DispatchEvent In Firefox I have some code that uses dispatchEvent to simulate clicks… String.fromCharCode Not Working On Keydown Event I am tyring to read the input characters on keydown event a… Getting DIV Id Based On X & Y Position The problem I'm trying to solve is 'What's at t… Coffeescript JQCloud Handlers I'm trying to do this in coffeescript, http://jsfiddle.… Set Anchor As Active With Jquery i have short question.. i got 3 content boxes and all have … Create A New Entity From Selection In Draft.js / /draftail, Wrap Existing Text And Link Entities I'm trying to create a new entity for Wagtail's Dra… Get And Update Text Every Few Seconds From An Http Source To An Https Website So, I have a radio station, my host provider does not have … JQuery Blur() Or Focusout() Not Firing In Internet Explorer So I have this form and I would like to do some stuff when … "Print" String Letter By Letter In React I have a React Native component that needs to show an Anima… Copy Contents Of Range Object (excel Column) To An Array Via Javascript what I want to do is access an excel file, take the content… December 2024 (1) November 2024 (40) October 2024 (72) September 2024 (22) August 2024 (381) July 2024 (342) June 2024 (709) May 2024 (1291) April 2024 (814) March 2024 (1566) February 2024 (1699) January 2024 (1367) December 2023 (1388) November 2023 (414) October 2023 (543) September 2023 (287) August 2023 (329) July 2023 (269) June 2023 (386) May 2023 (214) April 2023 (137) March 2023 (140) February 2023 (180) January 2023 (237) December 2022 (125) November 2022 (230) October 2022 (172) September 2022 (165) August 2022 (500) July 2022 (293) June 2022 (271) Menu Halaman Statis Beranda © 2022 - JavaScript Frameworks