Skip to content

Instantly share code, notes, and snippets.

@pospi
Created September 24, 2013 01:09
Show Gist options
  • Save pospi/6679110 to your computer and use it in GitHub Desktop.
Save pospi/6679110 to your computer and use it in GitHub Desktop.
Simple method for determining the number of periods between two dates
/**
* 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