Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the current date in the gnuplot title

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

Something like...

set title "date of execution = datetime()"

Thanks in advance.

Alexandre.

like image 334
user1680012 Avatar asked Nov 05 '25 21:11

user1680012


2 Answers

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
like image 199
Christoph Avatar answered Nov 07 '25 10:11

Christoph


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);
like image 36
John Doedoe Avatar answered Nov 07 '25 12:11

John Doedoe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!