JSFiddle - React, Tailwind, and code Playground

by somekittens

JavaScript

//So this can be run on JSFiddle
startDate = '2013-1-16';
endDate = '2013-1-30';

//HACKY HACK ALERT
//Node has timezone issues when using a straight new Date(req.body.startDate);
//So we'll need to do some hacky conversions.
var newDates = [];
[startDate, endDate].map(function(item) {
    var temp = item.split('-');
    console.log(temp);
    temp.forEach(function(otherItem, idx) {
        temp[idx] = parseInt(otherItem, 10);
    });
    console.log(temp);
    //temp[1] - 1 is needed because HTML 5 1-indexs months and node 0-indexes them
    newDates.push(new Date(temp[0], temp[1] - 1, temp[2]));
});
console.log(newDates);