I have converted the length of the movie Avatar from 2009, from minutes to timestamp. The movie is 162 minutes long so the timestamp is 1386227800. Now I need to convert the timestamp to hours and minutes which I don't know how.
In short: how can I convert a timestamp and get the correct result in hours and minutes?
I have tested floor(1386227800 / 60)
, date('H:i', mktime(0, 1386227800)
and some functions that converts a timestamp to hours and minutes, but these only converts the hours to something endless, like 12375
or something like that.
So, how can I accomplish this?
As one of the commenters mentioned, a timestamp represents a single point in time, not a duration. There's no reason to call strtotime at all -- if you already have the total minutes, you can ignore converting it to a timestamp and just get that into hours:minutes like this:
Can you try,
As I understand it, you want to convert 162 minutes to be represented with hours and minutes. This is a simple case of mathematics.
$hours
will return 2, and$minutes
will return 42. 2 hours, 42 minutes is equivalent to 162 minutes.Hope this helps.