能否在gnuplot标题中设置当前日期?
类似于...
set title "执行日期 = datetime()
"
提前感谢。
Alexandre.
使用strftime
和time(0)
将时间/日期添加到您的标题中,例如:
set title "data of execution ".strftime("%a %b %d %H:%M:%S %Y", time(0))
或者,如果不一定要在标题中,您也可以使用
set timestamp
被接受的答案是正确的。不幸的是,time(0)
和timestamp
都是UTC时间。您需要手动将UTC时间转换为您的本地时区。例如:
fmt = '%Y-%m-%d @ %H:%M:%S'; # Format used for printing out time
time_diff=8*60*60; # Seconds between local time zone and UTC
curr_time_utc = time(0); # Get UTC time
curr_time_pdt = curr_time_utc - time_diff; # Adjust to local time zone
print "Current time (UTC): ".strftime(fmt, curr_time_utc);
print "Current time (PDT): ".strftime(fmt, curr_time_pdt);
set output 'temperature.all_'.strftime('%Y-%m-%d', time(0)).'.png'
。 - McPeppr我刚刚添加了8小时的秒数来调整我的时区为+8。8x60x60 = 28800
设置标题 "上次运行时间:" .strftime("%a %b %d %H:%M", time(0)+28800)
完美解决。
Bj
datetime()
,这正是OP实际想要的,那么问题在哪里呢? - Christoph