문제

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