I'm trying to display date format as I wanted but none of the solutions did not work for me.
$(document).ready(function() {
var html = '';
var startDate = '07/04/2017';
var chunks = startDate.split('/');
var startformattedDate = chunks[1] + '-' + chunks[0] + '-' + chunks[2];
var endDate = '15/04/2017';
var chunks1 = endDate.split('/');
var endformattedDate = chunks1[1] + '-' + chunks1[0] + '-' + chunks1[2];
var start = new Date(startformattedDate);
var end = new Date(endformattedDate);
var data = [];
while (start <= end) {
data.push(new Date(start));
start.setDate(start.getDate() + 1);
}
for (i = 0; i < data.length; i++) {
html += '<tr><td>' + data[i] + '</td></tr>';
}
$('.Dates').append(html);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<table class="Dates">
</table>
I want to display the date either of below formats. How do I do that?
Fri Apr 07 2017 or Fri 7th Apr 2017
I tried using below formats but none of them does not match my desired output
new Date().toISOString()
new Date().toISOString().split('T')[0];
new Date().toISOString().replace('-', '/').split('T')[0].replace('-', '/');
new Date().toLocaleString().split(',')[0]
Any suggestions, please!