Created
September 24, 2013 01:09
-
-
Save pospi/6679110 to your computer and use it in GitHub Desktop.
Simple method for determining the number of periods between two dates
This file contains hidden or 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
| /** | |
| * usage: date/time date/time ms->sec->min->hour->day | |
| * getPeriodBetween('1 Jul 2011', '26 Oct 2010', 1000 * 60 * 60 * 24); | |
| * | |
| * = number of days between these two dates | |
| */ | |
| function getPeriodBetween(date1, date2, timescale) | |
| { | |
| return (new Date(date1) - new Date(date2)) / (timescale); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment