Adding a createTimeSpan() to Dates.. who knew?

Really short 'didn't know you could do that' moment.

Playing around with createTimeSpan() today in a little test bed, and gave this a try and it worked –


<cfscript>
    now = now();
   
    dts = createTimeSpan(0,2,0,0);
   
    then = now + dts;
</cfscript>

<cfoutput>
#TimeFormat(Now(), "HH:mm:ss")# : #TimeFormat(then, "HH:mm:ss")#
</cfoutput>
 

And look at that, that just added 2 hours to the time.

Normally I would have done that with a dateAdd(), but this actually quite quick.

Leave a Comment

Comments