Credits | Overview | Plotting Styles | Commands | Terminals |
---|
This command sets the default format used to input time data. See set xdata time, timecolumn.
Syntax:
set timefmt "<format string>" show timefmt
The valid formats for both timefmt and timecolumn are:
Format | Explanation |
---|---|
%d | day of the month, 1–31 |
%m | month of the year, 1–12 |
%y | year, 0–99 |
%Y | year, 4-digit |
%j | day of the year, 1–365 |
%H | hour, 0–24 |
%M | minute, 0–60 |
%s | seconds since the Unix epoch (1970-01-01 00:00 UTC) |
%S | second, integer 0–60 on output, (double) on input |
%b | three-character abbreviation of the name of the month |
%B | name of the month |
%p | two-character match to one of: am AM pm PM |
Any character is allowed in the string, but must match exactly. \t (tab) is recognized. Backslash-octals (\nnn) are converted to char. If there is no separating character between the time/date elements, then %d, %m, %y, %H, %M and %S read two digits each. If a decimal point immediately follows the field read by %S, the decimal and any following digits are interpreted as a fractional second. %Y reads four digits. %j reads three digits. %b requires three characters, and %B requires as many as it needs.
Spaces are treated slightly differently. A space in the string stands for zero or more whitespace characters in the file. That is, "%H %M" can be used to read "1220" and "12 20" as well as "12 20".
Each set of non-blank characters in the timedata counts as one column in the using n:n specification. Thus 11:11 25/12/76 21.0 consists of three columns. To avoid confusion, gnuplot requires that you provide a complete using specification if your file contains timedata.
If the date format includes the day or month in words, the format string must exclude this text. But it can still be printed with the "%a", "%A", "%b", or "%B" specifier. gnuplot will determine the proper month and weekday from the numerical values. See set format for more details about these and other options for printing time data.
When reading two-digit years with %y, values 69-99 refer to the 20th century, while values 00-68 refer to the 21st century. NB: This is in accordance with the UNIX98 spec, but conventions vary widely and two-digit year values are inherently ambiguous.
If the %p format returns "am" or "AM", hour 12 will be interpreted as hour 0. If the %p format returns "pm" or "PM", hours < 12 will be increased by 12.
See also set xdata time/date and time_specifiers for more information.
Example:
set timefmt "%d/%m/%Y\t%H:%M"
tells gnuplot to read date and time separated by tab. (But look closely at your data---what began as a tab may have been converted to spaces somewhere along the line; the format string must match what is actually in the file.) See also time data demo.