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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With