Skip to main content
Participant
September 15, 2008
Question

Override now() to "fake" system time?

  • September 15, 2008
  • 3 replies
  • 528 views
I've inherited an application that uses the now() function throughout to present the current time for use in queries, calculations, etc.
I don't have access to change the system time, so is there a way to override the output of the now() function instead of having to replace every instance of it with a variable?
Thanks.
    This topic has been closed for replies.

    3 replies

    Inspiring
    September 16, 2008
    MaryJo wrote:
    > As an interesting side note...this is something the Railo cfml
    > engine allows, to set the system time zone on a per-application basis.
    > So hopefully this will makes its way into ColdFusion as well eventually.

    Neat feature. That is good to know.

    Yes, I agree. I think the best you can do is to define your own function in your application.cfc. Give it a similar name like "cfTimeNow()". Then do a global replace in your code.
    Inspiring
    September 16, 2008
    Yeah,offhand I can't think of an easy way to do this without replacing the function with one of your own.

    As an interesting side note...this is something the Railo cfml engine allows, to set the system time zone on a per-application basis. So hopefully this will makes its way into ColdFusion as well eventually.

    Inspiring
    September 15, 2008
    I don't know if it will work, but you could write a udf called now() and cfinclude it somehow in your application.cfm/cfc file.
    RufhausenAuthor
    Participant
    September 15, 2008
    I'm afraid I get this if I try that:
    "The names of user defined functions cannot be the same as built-in ColdFusion functions."