Even simplier. The clock command is your friend 🙂
You must have a date/time string that is scanable. The clock scan command expects the date/time to be a list where the date is the first element and the time, if present, is the second element.
Given a GMT date/time in the format:
set datetime 20070626100505
An easy way to make it scanable is with regsub. This command will put a space between date and time, if there, else it will leave it as is if no time.
regsub — {(d{8})(d*)} $datetime {1 2} datetime
Then simply use the clock command to format to local time. Your OS time zone environment will be used for the difference between local and GMT
set local [clock format [clock scan $time -gmt 1]
-format %Y%m%d%H%M%S]
Assume you are on Central Time
echo $local
=> 20070626050505