This article example describes the method of js to obtain all dates between two dates. Share it for your reference, as follows:
<script>function getDate(datesstr){ var temp = datestr.split("-"); var date = new Date(temp[0],temp[1],temp[2]); return date;}var start = "2012-3-25";var end = "2012-4-3";var startTime = getDate(start);var endTime = getDate(end); while((endTime.getTime()-startTime.getTime())>=0){ var year = startTime.getFullYear(); var month = startTime.getMonth().toString().length==1?"0"+startTime.getMonth().toString():startTime.getMonth(); var day = startTime.getDate().toString().length==1?"0"+startTime.getDate():startTime.getDate(); alert(year+"-"+month+"-"+day); startTime.setDate(startTime.getDate()+1);}</script>For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of JavaScript traversal algorithms and techniques", and "Summary of JavaScript mathematical operations usage"
I hope this article will be helpful to everyone's JavaScript programming.