Timestamp or datetime calculate Lifetime/diff (php)

Asked

Viewed 67 times

0

Hello, I’m trying here how to do for this value "147878163" be converted to "1 day 17 hours 15 minutes" for example

Apparently it’s timestamp, but this value is different from what I usually use, because converting to datetime is 40 years ago... But the system shows that the service is being used 1 day 17 hours.... And when I use the API to rescue some values to integrate to my external system, the Lifetime key has this value "147878163" that in hours would be 1 day 17 days and such...

Can someone help me?

1 answer

1

That time is in milliseconds. Convert to 41.0772675 h hours

41h -24(one day) = 17

that is 1 day 17 hours

  • Ah.... OK.. I’ll try to do it here, I didn’t know it was milliseconds =D already put the results

  • Try it there. Anything ask here

  • I got it! Ai ta summing for example 30h now I need to make it 1 day and 6h - The code - $total = ($Lifetime/1000); $hours = (strlen(floor($total / 3600)) == 1) ? " 0". floor($total / 3600)."": floor($total / 3600); $minutos = (strlen(floor(($total - ($hours * 3600)) / 60)) == 1) ? " 0". floor(($total - ($hours * 3600)) / 60)."": floor(($total - ($hours * 3600)) / 60); $seconds = (strlen(floor($total % 60)) == 1) ? " 0". floor($total % 60)."": floor($total % 60); $Lifetime = $hours . ":" . $minutes . ":" . $seconds; as jumps line here ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.