Created
December 5, 2015 20:44
-
-
Save aug2uag/12fed52b50ea0e3c6c47 to your computer and use it in GitHub Desktop.
delta months between two JS Date objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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