JSFiddle - React, Tailwind, and code Playground
by mwfire
HTML
<script src="https://raw.githubusercontent.com/moment/moment/develop/moment.js"></script>
JavaScript
function getTomorrow() {
var tomorrow = moment().utc().add('days', 1).hour(0).minute(0).seconds(0);
var tomorrowEnd = moment(tomorrow).utc().hour(23).minute(59).seconds(59);
return {
startDate : tomorrow,
endDate : tomorrowEnd
}
}
function getThisWeek() {
var today = moment().utc();
var daysTo = 7 - today.isoWeekday();
var thisSunday = moment().utc().add('days', daysTo);
thisSunday.hour(23).minute(59).seconds(59);
return {
startDate : today,
endDate : thisSunday
}
}
function getNextWeek() {
var nextMonday = moment().utc().startOf('isoWeek').add('days', 7);
var nextSunday = moment(nextMonday).utc().add('days', 6);
nextSunday.hour(23).minute(59).seconds(59);
return {
startDate : nextMonday,
endDate : nextSunday
}
}