Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-12-2012, 01:35 AM   PM User | #1
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
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..
sonny is offline   Reply With Quote
Old 10-12-2012, 01:57 AM   PM User | #2
Len Whistler
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
Len Whistler is on a distinguished road
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
__________________
Leonard Whistler

Last edited by Len Whistler; 10-12-2012 at 02:02 AM..
Len Whistler is offline   Reply With Quote
Users who have thanked Len Whistler for this post:
sonny (10-12-2012)
Old 10-12-2012, 05:11 AM   PM User | #3
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
Thank You so much
Sonny
sonny is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:49 AM.


Advertisement
Log in to turn off these ads.