weiter 7 Tage in Dropdown-Liste [duplizieren]

Diese Frage hat hier bereits eine Antwort:

Wie bekomme ich die nächsten sieben Tage von X und formatiere in JS 6 answers

Ich möchte, dass die nächsten 7 Tage in einer Dropdown-Liste angezeigt werden. Mein Code scheint jedoch nicht zu funktionieren.

Bitte beachten Sie, dass das Datumsformat @ sein muyyyy-mm-dd.

Kannst du mir bitte Helfen. Hier ist mein Code:

function formatDate(date) {
    var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();

    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;

    return [year, month, day].join('-');
}
var curr = new Date;
var first = curr.getDate()
var firstday = (new Date(curr.setDate(first))).toString();
for (var i = 0; i < 7; i++) {
    var next = new Date(curr.getTime());
    next.setDate(first + i);
    options += '<option>' + formatDate((next.toString())) + '</option>';
}

$("#datemenu1").append(options);
$("#datemenu1").html("<option>PICK A DATE</option>");
<html>

<select id="datemenu1">
  
  <option>PICK A DATE</option>
  
</select>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="Text-1.js"></script>strong text
</html>

Geig

Antworten auf die Frage(6)

Ihre Antwort auf die Frage