Forum Discussion

Steds84_8430's avatar
Steds84_8430
Icon for Nimbostratus rankNimbostratus
Sep 15, 2009

Clock add?

I am having trouble with the clock add function, could anyone give me an example has to how I would add a number of minutes to the current time

 

 

So far I have tried

 

 

set e [clock add [clock seconds] 10 minutes]

 

 

it returns an error : [invalid option "add" must be: clicks format scan seconds] [add]

 

 

 

that to me says that the add sub-function does not exist, yet the tcl reference says otherwise?

 

 

I am quite new to iRules and Tcl so any help would be appreciated, even if it means a work around.

 

 

 

Brett.

3 Replies

  • Hi Brett,

     

     

    iRules use TCL v8.4.x (You can use [info tclversion] Click here to verify this).

     

     

    clock add was added in 8.5 (v8.5 release notes Click here). For time deltas, it's probably easier to get the time in unix time (seconds since the 1 Jan 1970 epoch using [clock seconds]) and then just use expr (Click here) to do the calculations.

     

     

    If that doesn't work for your scenario, can you elaborate on it?

     

     

    Thanks,

     

    Aaron
  • Thanks for the quick reply, Aaron. I was probably over complicating a little, using the clock add. The clock seconds and expr method should work just fine.

     

     

    Thanks again,

     

     

    Brett.
  • Hi Aaron,

     

    thank you from my side as well, I also had the same syntax error as mentioned by Brett and got it working now with the expr option.

     

    Ciao Stefan :)