clock format from ISO8601 to numerical

Hello,

I have variable with a timestamp like this “2017-04-26T15:09:49.228Z” and I need to convert to numerical (just seconds).

I try

[clock format $nbf -format {%s}]

I get a TCL error “- expected integer but got “2017-04-26T15:09:49.228Z” while executing “clock format $nbf -format {%s}””

Have anyone a idea how I can solve this format problem?

Hi,

you can use this:

set time "2017-04-26T15:09:49.228Z"
set time [string range $time 0 [string first "." $time]-1]
clock scan $time -format {%Y-%m-%dT%H:%M:%S}