home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / createtimespan.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  2.5 KB  |  62 lines

  1. <!--- This example shows how to createTimeSpan --->
  2. <HTML>
  3.  
  4. <HEAD>
  5. <TITLE>
  6. CreateTimeSpan Example
  7. </TITLE>
  8. </HEAD>
  9.  
  10. <BODY bgcolor=silver>
  11.  
  12. <H3>CreateTimeSpan Example</H3>
  13.  
  14. <CFIF IsDefined("form.year")>
  15.  
  16. <!--- set variables for the date and for the time span --->
  17. <CFSET yourDate = #CreateDateTime("#form.year#","#form.month#","#form.day#", "#form.hour#","#form.minute#","#form.second#")#>
  18. <CFSET yourTimeSpan = #CreateTimeSpan("#form.tsday#","#form.tshour#","#form.tsminute#","#form.tssecond#")#>
  19.  
  20. <CFOUTPUT>
  21. <P>Your original date value: #yourDate#
  22. <P>The date of your timespan, formatted:
  23.  
  24. <!--- output the results of the form --->
  25. <P>#yourTimeSpan# days <CFIF #yourTimeSpan# LTE 0>before your<CFELSE>after your</CFIF> original date:
  26. <BR>#DateFormat("#yourDate#" + "#yourTimeSpan#")#
  27.  #TimeFormat("#yourDate#" + "#yourTimeSpan#")#
  28.  
  29. </CFOUTPUT>
  30.  
  31. </CFIF>
  32.  
  33.  
  34. <CFFORM ACTION="createtimespan.cfm" METHOD="POST">
  35. <P>Please enter the year, month and day in integer format for 
  36. the date value you would like to view:
  37. <PRE>
  38. Year    <CFINPUT TYPE="Text" NAME="year" VALUE="1998" VALIDATE="integer" REQUIRED="Yes">
  39. Month    <CFINPUT TYPE="Text" NAME="month" VALUE="6" RANGE="1,12" MESSAGE="Please enter a month (1-12)" VALIDATE="integer" REQUIRED="Yes">
  40. Day    <CFINPUT TYPE="Text" NAME="day" VALUE="8" RANGE="1,31" MESSAGE="Please enter a day of the month (1-31)" VALIDATE="integer" REQUIRED="Yes">
  41. Hour    <CFINPUT TYPE="Text" NAME="hour" VALUE="16" RANGE="0,23" MESSAGE="You must enter an hour (0-23)" VALIDATE="integer" REQUIRED="Yes">
  42. Minute    <CFINPUT TYPE="Text" NAME="minute" VALUE="12" RANGE="0,59" MESSAGE="You must enter a minute value (0-59)" VALIDATE="integer" REQUIRED="Yes">
  43. Second    <CFINPUT TYPE="Text" NAME="second" VALUE="0" RANGE="0,59" MESSAGE="You must enter a value for seconds (0-59)" VALIDATE="integer" REQUIRED="Yes">
  44.  
  45. The time span you'd like to show
  46. Day    <CFINPUT TYPE="Text" NAME="tsday" VALUE="16" VALIDATE="integer" MESSAGE="You must enter a value for the number of days in advance" REQUIRED="Yes">
  47. Hour    <CFINPUT TYPE="Text" NAME="tshour" VALUE="16" MESSAGE="You must enter a value for the number of hours" VALIDATE="integer" REQUIRED="Yes">
  48. Minute    <CFINPUT TYPE="Text" NAME="tsminute" VALUE="12" MESSAGE="You must enter a value for the number of minutes" VALIDATE="integer" REQUIRED="Yes">
  49. Second    <CFINPUT TYPE="Text" NAME="tssecond" VALUE="0" MESSAGE="You must enter a value for the number of seconds" VALIDATE="integer" REQUIRED="Yes">
  50.  
  51. </PRE>
  52. <P><INPUT TYPE="Submit" NAME=""> <INPUT TYPE="RESET">
  53.  
  54.  
  55. </CFFORM>
  56.  
  57.  
  58.  
  59. </BODY>
  60.  
  61. </HTML>       
  62.