home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Documentation / snippets / createtimespan.cfm < prev    next >
Encoding:
Text File  |  1999-04-12  |  2.5 KB  |  63 lines

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