Converts a duration into milliseconds, seconds, minutes, hours, days, weeks, months and years. Months and years use the Gregorian average: a year of 365.2425 days, and a month of a twelfth of that.
This converts a duration between milliseconds, seconds, minutes, hours, days, weeks, months and years. From minutes down it is a clean business of 60s and 24s.
Calendar months run from 28 to 31 days, and leap years shift the year by a day. Months and years can therefore only be converted on average. The figures here use the Gregorian average: a year of 365.2425 days and a month of a twelfth of that. In seconds those come to 31556952 and 2629746, both exactly whole numbers.
A day is 86400 seconds, 1440 minutes and 24 hours. It is 0.142857 of a week, 0.0329 of an average month and 0.00274 of a year. Turned around, a year is 8765.82 hours, a little short of ten thousand.
The Gregorian calendar adds a leap day every four years, skips it every hundred, and restores it every four hundred. That is 97 leap years in 400, giving an average of days.
To count the days in a particular stretch of time, use the calendar rather than these averages. A month spanning February and one spanning July differ by three days.