Reputation: 31
I am using TCL 8.6 version and trying to "get current time with milliseconds" using TCL.
Output I am willing to get is as below: using example time
11:06:52.123
Upvotes: 2
Views: 11075
Reputation: 247210
set t [clock milliseconds]
set timestamp [format "%s.%03d" \
[clock format [expr {$t / 1000}] -format %T] \
[expr {$t % 1000}] \
]
Looking back at this, I'd use a helper proc to tidy things up:
proc divmod {numerator divisor} {
list [expr {$numerator / $divisor}] [expr {$numerator % $divisor}]
}
lassign [divmod [clock milliseconds] 1000] sec milli
set timestamp [format {%s.%03d} [clock format $sec -format %T] $milli]
Upvotes: 13