Skip to content

Instantly share code, notes, and snippets.

@KartaviK
Created October 29, 2019 12:40
Show Gist options
  • Save KartaviK/c24c306df446bac3814a8df40d1043bd to your computer and use it in GitHub Desktop.
Save KartaviK/c24c306df446bac3814a8df40d1043bd to your computer and use it in GitHub Desktop.
Calculate remaining days to next month
function remainingDays(date) {
let time = new Date(date.getTime());
time.setMonth(date.getMonth() + 1);
time.setDate(0);
return time.getDate() > date.getDate() ? time.getDate() - date.getDate() : 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment