-3

Possible Duplicates:
Calculating the difference between two dates
What’s the best way to calculate date difference in Javascript

How can I find difference between two dates in JavaScript?

Community
  • 1
  • 1
chandu
  • 1
  • 1
  • 3
    Take your pick on the dupes -- http://stackoverflow.com/search?q=date+difference+javascript. I went with [Calculating the difference between two dates](http://stackoverflow.com/questions/1410285/calculating-the-difference-between-two-dates) – Andy E May 27 '10 at 12:55
  • I thought [327429](http://stackoverflow.com/questions/327429/whats-the-best-way-to-calculate-date-difference-in-javascript) was a closer dup. – T.J. Crowder May 27 '10 at 13:01

3 Answers3

1
 return date1 - date2;
 // returns the number of microseconds between the two `Date`s.
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • @OP: Yes, really, it's *that* easy. :-) The result is a number, in milliseconds. You have to be careful with historical dates, though, Javascript's Date object doesn't handle the Gregorian change in 1582. For contemporary dates, though, it's fine. – T.J. Crowder May 27 '10 at 12:57
0

http://www.javascriptkit.com/javatutors/datedifference.shtml

vakuras
  • 987
  • 6
  • 10
0

Do you mean something like this?

http://www.mcfedries.com/JavaScript/DaysBetween.asp

pasuna
  • 1,405
  • 2
  • 15
  • 21
  • 2
    No link-only answers, please. SO should stand on its own; external links can disappear, get renamed, etc. – T.J. Crowder May 27 '10 at 12:58
  • aa ok, my bad. I will post the main idea from the link – pasuna May 28 '10 at 06:18
  • but something like this: ` ` – pasuna May 28 '10 at 06:22