0

I am trying to calculate the number of days since a given date.

today = new Date();
time = today - mydate;
days = Math.floor(time / (1000*60*60*24));

This returns the correct value only if mydate is set to a time before the current time. In other words, if mydate is yesterday at 10 pm and I run this in the morning, I get 0 when I want 1.

Alesh Houdek
  • 938
  • 2
  • 7
  • 20

0 Answers0