Forum Discussion
eschurma_27945
Nimbostratus
Oct 24, 2007Retrieving time in milliseconds? (using v. 9.1.2)
I am trying to retrieve the current time, down to the number of milliseconds. I can't find any way to do this (I am using v9.1.2). If I use "clock milliseconds" I get the error
01070151:3: Rule [timestamp_remove_add2] error:
line 3: [invalid option "milliseconds" must be: clicks format scan seconds] [milliseconds]
line 5: [command is not valid in the current scope] [}]
"clock seconds" works fine. I can use "clock clicks -milliseconds", but that doesn't give me the actual time - just the click count expressed in milliseconds, which doesn't seem to be tied to any meaningful zero point. Is there any way to get the current actual time down to the millisecond level?
Thanks!
Eric
- JRahm
Admin
Try this:when CLIENT_ACCEPTED { set secs [clock seconds] set msec [clock clicks -milliseconds] set base [expr { $secs * 1000 } ] set fract [expr { $msec - $base }] if { $fract >= 1000 } { set diff [expr { $fract / 1000 }] incr secs $diff incr fract [expr { -1000 * $diff }] } log local0. "Timestamp with milliseconds is [clock format $secs -format {%H:%M:%S}].$fract" }
- eschurma_27945
Nimbostratus
would that work? Doesn't it assume that the clicks started on a second boundary? The TCL docs say that clicks aren't aligned with any particular epoch. - JRahm
Admin
Yes, but it's the closest way I could think of to get you to your desired goal.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects