It's possible to set the current date in the gnuplot title?

Something like...

set title "date of execution = datetime()"

Thanks in advance.

Alexandre.

有帮助吗?

解决方案

Use strftime and time(0) to add a time/data to your title, e.g.:

set title "data of execution ".strftime("%a %b %d %H:%M:%S %Y", time(0))

Alternatively, if it doesn't have to be in the title you can also use

set timestamp

其他提示

The accepted answer is correct. Unfortunately, both time(0) and timestamp are UTC. You need to manually convert UTC to your local time zone. For example:

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);

I just added 8 hours in seconds to time to adjust for my Timezone of +8. 8x60x60 = 28800

set title "Last Run: " .strftime("%a %b %d %H:%M", time(0)+28800)

Works a treat.

Bj

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top