algorithm - How to get the number of years, months, days, hours and mins of a certain number of seconds? -



algorithm - How to get the number of years, months, days, hours and mins of a certain number of seconds? -

given arbitrary number of seconds, how can number of years, months, days, hours , mins?

the algorithm should first compute maximum number of years, number of months , on...

what efficient way this?

it's downwards plain division. may know...

a min has 60 seconds: number_of_minutes := floor(number_of_seconds / 60)

an hr has 60 minutes: number_of_hours := floor(number_of_minutes / 60) or number_of_hours := floor(number_of_seconds / (60 * 60))

a day has 24 hours (at to the lowest degree usually... see below.)

a month has between 28 31 days.

a year has 365 or 366 days, or 365.2425 days on average.

the lastly 2 mentioned may require think more stated problem. either define "average" month, allows "x seconds equal y average months"; or don't convert seconds months @ all.

(thinking it, if talking astronomer or alike, tell day not 24 hours, due occasional jump second.)

algorithm date time seconds

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -