The other day, I discovered how to get the date/time at which your ColdFusion page started running. Before I had found this, I had contemplated using a GetTickCount() at the beginning of my page run to mark this time. But, this method is ganky and requires updates to more than one file. By reaching into the Page Context, I am able to grab the start date/time value of the page without having to modify any other templates:
<!--- Use the page and fusion context objects to get the date/time stamp at which this page started processing. Then, get the number of seconds that that start date is smaller than the current date/time stamp value. ---> <cfset intRunTimeInSeconds = DateDiff( "s", GetPageContext().GetFusionContext().GetStartTime(), Now() ) /> <!--- Output the number of seconds in which the page has been processing. ---> <p> Page has been processing for: #intRunTimeInSeconds# Seconds </p>
Running the above, I get the output:
Page has been processing for: 0 Seconds
Zero seconds; not surprising considering the page has what amounts to like three lines of code on it. While this might seem completely insignificant, this is a very cool thing to know. I will go into that a bit more next.
Want to use code from this post? Check out the license.