SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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. #2
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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. #3
    John 8:24 JREAM's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey that works just great thank s

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote 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.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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


Bookmarks

Posting Permissions

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