Skip to content

Instantly share code, notes, and snippets.

@aug2uag
Created December 5, 2015 20:44
Show Gist options
  • Save aug2uag/12fed52b50ea0e3c6c47 to your computer and use it in GitHub Desktop.
Save aug2uag/12fed52b50ea0e3c6c47 to your computer and use it in GitHub Desktop.
delta months between two JS Date objects
function monthDiff(d1, d2) {
var months;
months = (d2.getFullYear() - d1.getFullYear()) * 12;
months -= d1.getMonth() + 1;
months += d2.getMonth();
return months <= 0 ? 0 : months;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment