nowdate = new Date(); wardate = new Date(); var d = (nowdate.getFullYear() - wardate.setFullYear(1945)) / 1000 / 24 / 12; document.write(d); I need a script that calculates how many years have passed since 1945. The variable d takes a value in milliseconds, how to translate it into years?
31600800000by31600800000, obviously. - etki(new Date('2015-01-01').getTime() - new Date('1945-01-01').getTime())/31600800000 -> 69.90293916609706. The365.25 * 24 * 60 * 60 * 1000that the resulting number should be divided by the number of milliseconds per year, and it can be recognized as a product of365.25 * 24 * 60 * 60 * 1000(we believe that we have the same year). - etki