JavaScript syntax to find dates within last three years -


what proper syntax see if given date falls within 3 years todays date? need 3 years not take year of todays date , subtract 3 may not 3 full years ago. in other words if mid way through year. need go mid way through year 3 years ago.

basically have records have dates attached them , want display them if between today , 3 years ago.

thanks

date objects can subtracted give difference in milliseconds:

var = new date; var = new date(2008, 10, 7);  if ((now - then) < 1000 * 60 * 60 * 24 * 365 * 3) 

1000 * 60 * 60 * 24 * 365 * 3 3 years in milliseconds, discounting leap years , leap seconds.


Comments

Popular posts from this blog

haskell - Using filter on an item in a list? -

c# - When does PreApplicationStartMethod actually get triggered to run? -

c# - Binding attached property to IEnumerable -