How to get last quarter dates. JavaScript
function getLastQuarterDates() { var quarter, year; if(moment().quarter() == 1){ quarter = 4; year = moment().subtract(1, 'year').format("YYYY"); } else{ quarter = moment().quarter() -1; year = moment().format("YYYY"); } var firstDate = moment('1.'+( (quarter*3) - 2) + "." + year, "DD.MM.YYYY"); var lastDate = moment('1.'+( (quarter*3)) + "." + year, "DD.MM.YYYY").endOf('month'); return { 'firstDate' : firstDate, 'lastDate' : lastDate, 'year': year, 'quarter': quarter }; }
- Read more about How to get last quarter dates. JavaScript
- Log in to post comments