Ok, say I have a number, such as "8752". How can I convert that to time? I want to know how many years, months, days, hours, minutes and seconds 8752 seconds is. How would I find this? Thanks! 😃
$secs = 8752; $mins = floor($secs/60); $secs = $secs % 60; $hrs = floor($mins/60); $mins = $mins % 60; $days = floor($hrs/24); $hrs = $hrs % 24; echo "$days days $hrs:$mins:$secs"
Beyond that months become a stumbling block. It depend on where you are in the year as they're different lengths
if "8752" is a Unix timestamp() and you want find out what date it represesnts you could use date() with the optional parameter.
Smth like this: date('U', 8752)
Originally posted by cosminb if "8752" is a Unix timestamp() and you want find out what date it represesnts you could use date() with the optional parameter. Smth like this: date('U', 8752)
8752 is a unix timestamp in the future minus the current unix timestamp. I want to find the months, days, etc. until that future unix timestamp.
You could [man]getdate/man with both timestamps and subtract the respective array elements
Originally posted by barand You could [man]getdate/man with both timestamps and subtract the respective array elements
Remembering to carry when you get negative numbers for each element; an hour is sixty minutes, a minute is usually sixty seconds, and a day is usually twenty-four hours....