W
W
weslyg2016-10-04 15:46:11
JavaScript
weslyg, 2016-10-04 15:46:11

Where does the extra day come from in date js?

31556926 seconds in a year 2629743 seconds
in a month There are 2 dates in a
day 86400 seconds .
Exactly 22 years and 2 months later.
var main = new Date("1994.08.04");
var now = new Date ("2016.08.04""); Counting
:
now-main = 699643567730(milliseconds in the difference between dates)
699643567730/1000/31556926 (find out the number of years in Seconds(!))
=22.17084033248359
699640356073 %31556926 (we take the remainder of the division to calculate the number of months)
5391195/2629743 (the result of the last operation divided by the number of seconds in the month)
=2.0500843618558924 (everything is ok!)
5391195%2629743 (we take the remainder of this division to find out the number of days)
=131709
131709/86400 (divide the remainder of the last division by the number of seconds in a day)
=1.5244097222222222
Question: Whence 1.5 days in an even period of time? from 4 to 4 number?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Ineshin, 2016-10-04
@IonDen

What about leap year?

N
Nicholas, 2016-10-04
@healqq

Did you forget about leap years?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question