JSFiddle - React, Tailwind, and code Playground

by Graham Fairweather

JavaScript

function firstDayOfMonth() {
    var d = new Date(Date.apply(null, arguments));

    d.setDate(1);
    return d.toISOString();
}

function lastDayOfMonth() {
    var d = new Date(Date.apply(null, arguments));

    d.setMonth(d.getMonth() + 1);
    d.setDate(0);
    return d.toISOString();
}

var now = Date.now();

console.log(firstDayOfMonth(now));
console.log(lastDayOfMonth(now));