# Thread: Making 23.8833333 turn to Hours and Minutes

1. ## Making 23.8833333 turn to Hours and Minutes

I have this number:
23.883333333333

I have already went from calculating a DATETIME to the current DATETIME, so I calculated the difference.

I would like to know how many hours and minutes that is.

I know its 23 hours and maybe like 50 minutes,
because there are 60 minutes in an hour.

So I was thinking I should number_format it.
But how do I make so that it shows the minutes in minutes?

(This part below probably isnt useful)
I tried something like this but I get 07:12
I don't know what that means.
PHP Code:
``` // Cuz there are 1440 Minutes in a Day     \$this->AHH = (1440 - \$this->Time) / 60;            \$stt = strtotime(\$this->AHH);            \$ee = date('h:m' , \$stt);  ```

2. Little confused by the question, but here's my response, with out really doing anything

If the Format is in hours and you want to get the number of minutes you could do a couple of things

\$input = 23.883333333333
list(\$hours) = explode('.', \$input);
\$minutes = (\$input - \$hours) * 60;

3. hey that works just great thank s

4. Originally Posted by JREAM;4426008(This part below probably isnt useful)
I tried something like this but I get [B
07:12[/B]
I don't know what that means.
You messed up the calculation by subtracting from 1440 in the first place.

5. It is is not PHP question.
It is elementary school math question. Hope you attended to.

General way for time calculations in php is to count seconds and then convert to hours.
Also, if it's mysql datetime, mysql has a lot of date calculationg functions,
http://dev.mysql.com/doc/refman/5.1/...functions.html
and I am sure they have one for your case too

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•