Hi all,
I have been struggling with a problem all day, I have been unable to come
up with a working solution.
I want to write a function which takes 2 unix timestamps and calculates
the difference. I want it to return the difference in years, months, days,
hours, minutes and seconds (a complete summary). Keeping into account of
course that these are 2 real dates, I dont want it to work with 30.475 as
an average number of days in a month, I want it to work with the supplied
months/years.
The output ought to be: there is 0 years, 7 months, 12 days, 5 hours,
56 minutes and 51 seconds difference.
(I dont want the difference as in 1237438424 seconds but a complete
summary).
Any of my attempts have failed. It is easy to calculate the numbers of
seconds, minutes, hours and days (total only). But I cant get passed
calculating the number of months and years. Furthermore, any of the
libraries from the internet which I have tested seem to be flawed as well,
their results are not precise.
Can this not be done? Anyone?
Kind regards,
Hans Gruber
I have been struggling with a problem all day, I have been unable to come
up with a working solution.
I want to write a function which takes 2 unix timestamps and calculates
the difference. I want it to return the difference in years, months, days,
hours, minutes and seconds (a complete summary). Keeping into account of
course that these are 2 real dates, I dont want it to work with 30.475 as
an average number of days in a month, I want it to work with the supplied
months/years.
The output ought to be: there is 0 years, 7 months, 12 days, 5 hours,
56 minutes and 51 seconds difference.
(I dont want the difference as in 1237438424 seconds but a complete
summary).
Any of my attempts have failed. It is easy to calculate the numbers of
seconds, minutes, hours and days (total only). But I cant get passed
calculating the number of months and years. Furthermore, any of the
libraries from the internet which I have tested seem to be flawed as well,
their results are not precise.
Can this not be done? Anyone?
Kind regards,
Hans Gruber
Comment