Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts

    divide miles, speed time formating

    Hi, I am trying to display in minutes, instead of 0.2 hr etc
    like the example below will do, now I know every .1 = 6 min
    I am just stumped on how to get this to display 12 minutes.

    PHP Code:
    $sum round(11 55,1);// example 11 miles
    echo $sum
    I am trying to display things in minutes only when under 1 hour
    anyone know how to multiply just that number after the decimal by 6?

    Thanks
    Sonny
    Last edited by sonny; 10-12-2012 at 05:11 AM.

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    PHP Code:
    $sum round(11 55,1);// example 11 miles

    $hours floor($sum);
    $minutes = ($sum $hours)*60;


    echo 
    "$hours hours and $minutes minutes"
    Output
    Code:
    0 hours and 12 minutes
    Last edited by Len Whistler; 10-12-2012 at 02:02 AM.
    Leonard Whistler

  • Users who have thanked Len Whistler for this post:

    sonny (10-12-2012)

  • #3
    Regular Coder sonny's Avatar
    Join Date
    Apr 2008
    Location
    United States
    Posts
    567
    Thanks
    88
    Thanked 0 Times in 0 Posts
    Thank You so much
    Sonny


  •  

    Posting Permissions

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