ColdFusion Tutorial

Convert hours to minutes and minutes to hours

There are no predefined functions in CFML for this, so we have to write some lines of code.

The code:

<cfset tot_minutes = "145">
<!--- Convert to h/m --->
<cfset hours = int(tot_minutes/60)>
<cfset minutes = int(tot_minutes MOD 60)>

<cfoutput>#tot_minutes# minutes: #hours# hours and #minutes# minutes.</cfoutput>

<br>

<!--- Convert back to minutes --->
<cfset tot_minutes_back = (hours * 60) + minutes>

Total minutes: <cfoutput>#tot_minutes_back#</cfoutput>

The output:

145 minutes: 2 hours and 25 minutes.
Total minutes: 145

ColdFusion Tutorial test

Convert hours to minutes and minutes to hours

No test is available or implemented for this ColdFusion Tutorial.

User Comments: 1

 Converting minutes to hours....

how do I convert minutes to hours by using a simple dividing technique?
Sample: 150 minutes = 2 1/2 hours.

I can do that one in my head (!!) but if it comes to larger numbers, this becomes more difficult...
We need an answer that breaks down to hours and then 1/4, 1/2 and 3/4 hours.
What simple way is there to do that?

Add your comments

Your Name*:
Your Email:
Site URL:
Site Name:
Comemt Title*:
Your Comment*:
Key Phrase*:
yW2
Your IP Address: 38.103.63.62
 

ScandicWeb is own by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.

[Home [Site Map [Privacy Statement [Site Feedback] [About ScandicWeb]


[ColdFusion [Flash [Search Engine Optimization [Graphics [Cascading Style Sheets (CSS) [JavaScript (JS) [Software]

Partner sites: ScandicSoft


Server time: 19. November 2008 Wednesday