set a [clock scan now] ;# today's date
puts [clock format $a]
puts "Enter a number up to where you have to increase"
set var [gets stdin]
set var [scan $var %d]
set a [clock scan {$var days} -base [clock seconds]]
puts [clock format $a]
显示一些错误
无法转换日期时间字符串“$ var days”
答案 0 :(得分:3)
您使用的是错误的引号:
clock scan {$var days} ;# non-interpolating quotes: "doesn't work"
clock scan "$var days" ;# OK
尝试使用clock add
进行日期算术
% set a [clock seconds]
1507652391
% clock format $a
Tue Oct 10 12:19:51 DST 2017
% set var 5
5
% set b [clock add $a $var days]
1508084391
% clock format $b
Sun Oct 15 12:19:51 DST 2017
% set var -2
-2
% set b [clock add $a $var days]
1507479591
% clock format $b
Sun Oct 08 12:19:51 DST 2017