Website Administered by: Michael Falatine (remove "1" from end when emailing)
Released: 12/27/2004
Basic Description:
Script allows developers to easily embed the functionality of calculating end time from a given start time and span into in 1/2 hour increments.

Tested in: Firefox BrowserFirefox, Internet Explorer BrowserInternet Explorer, Netscape BrowserNetscape, Opera BrowserOpera

Features List:
  • REQUIRES Cold Fusion 5.0 or MX to run
  • Uses "CreateTimeSpan" to translate both start time and time span into minutes.  That way only a simple addition is required to determine end time.
  • "TimeFormat" is then used to return the start time and end time back to a HH:MM based time format.
  • Several of the "TimeFormat" formatting options are provided with this script.
  • Page "actions" back to itself, therefore, "cfparam" is required to setup two default parameters (RequestTimeStart, RequestTimeAmount) for initial page load.
Demonstration of Code:
Start Time: Amount of Time: Hours
Start Time:
12 hour: 12:00 AM
24 hour: 00:00
End Time (Start Time + Amount):
12 hour: 12:00 AM
24 hour: 00:00
Code considerations:
The primary function centers around the following:

<!--- Functions to determine end time --->
<cfset x=CreateTimeSpan(0, 0, RequestTimeStart, 0)>
<cfset y=CreateTimeSpan(0, 0, RequestTimeAmount, 0)>
<cfset z=x+y>

Within the parenthesis of the CreateTimeSpan, the variables (gathered from the above form set as minutes) are placed in the "minutes" spot.  "x" is the start time in minutes.  "y" is the time span in minutes.  Adding these together give a total minutes for end time.

Note: if the end time is past 12:00 am then it is obviously the next day, but the function still works fine.  Additional code is required to calculate whether the end time is in the next day or not if required.

To get the values in an HH:MM format, TimeFormat is used accordingly.

Get the Code:
Download the .zip file containing everything here
Top of Page

Valid HTML 4.01!

Views: 1803

Valid CSS!