Introduction
This document refers to OpenTelemetry (OTEL) detailing the supported timestamp formats within the OTEL specification. In OpenTelemetry (OTEL), the timestamps can be formatted in various ways and support multiple timestamp formats to accommodate different preferences and requirements. This document outlines some of the timestamp formats available for representing timestamps in OTEL-compliant systems.
Strptime
The strptime refers to a function or method used for parsing timestamps according to a specified format string.
Expression | Description |
---|---|
%Y | Year, zero-padded (0001, 0002, ..., 2019, 2020, ..., 9999) |
%y | Year, last two digits, zero-padded (01, ..., 99) |
%m | Month as a decimal number (01, 02, ..., 12) |
%o | Month as a space-padded number (1, 2, ..., 12) |
%q | Month as an unpadded number (1,2,...,12) |
%b, %h | Abbreviated month name (Jan, Feb, ...) |
%B | Full month name (January, February, ...) |
%d | Day of the month, zero-padded (01, 02, ..., 31) |
%e | Day of the month, space-padded (1, 2, ..., 31) |
%g | Day of the month, unpadded (1,2,...,31) |
%a | Abbreviated weekday name (Sun, Mon, ...) |
%A | Full weekday name (Sunday, Monday, ...) |
%H | Hour (24-hour clock) as a zero-padded decimal number (00, ..., 24) |
%I | Hour (12-hour clock) as a zero-padded decimal number (00, ..., 12) |
%p | Locale’s equivalent of either AM or PM |
%P | Locale’s equivalent of either am or pm |
%M | Minute, zero-padded (00, 01, ..., 59) |
%S | Second as a zero-padded decimal number (00, 01, ..., 59) |
%L | Millisecond as a decimal number, zero-padded on the left (000, 001, ..., 999) |
%f | Microsecond as a decimal number, zero-padded on the left (000000, ..., 999999) |
%s | Nanosecond as a decimal number, zero-padded on the left (000000, ..., 999999) |
%z | UTC offset in the form ±HHMM[SS[.ffffff]] or empty(+0000, -0400) |
%Z | Timezone name or abbreviation or empty (UTC, EST, CST) |
%D, %x | Short MM/DD/YY date, equivalent to %m/%d/%y |
%F | Short YYYY-MM-DD date, equivalent to %Y-%m-%d |
%T, %X | ISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S |
%r | 12-hour clock time (02:55:02 pm) |
%R | 24-hour HH:MM time, equivalent to %H:%M |
%n | New-line character ('\n') |
%t | Horizontal-tab character ('\t') |
%% | A % sign |
%c | Date and time representation (Mon Jan 02 15:04:05 2006) |
gotime
The gotime layout type utilizes Go’s native time parsing capabilities. Go’s approach to time parsing may differ from other programming languages, and it is well-documented in the Go Documentation, providing comprehensive information on finer details.
epoch
The epoch refers to the Unix epoch time, which represents the number of seconds or milliseconds elapsed since the Unix epoch. The Unix epoch is defined as 00:00:00 UTC on January 1, 1970.
Layout | Meaning | Example | Data Type Support |
---|---|---|---|
s | Seconds since the epoch | 1136214245 | string, int64, float64 |
ms | Milliseconds since the epoch | 1136214245123 | string, int64, float64 |
us | Microseconds since the epoch | 1136214245123456 | string, int64, float64 |
ns | Nanoseconds since the epoch | 1136214245123456789 | string, int64, float64[2] |
s.ms | Seconds plus milliseconds since the epoch | 1136214245.123 | string, int64[1], float64 |
s.us | Seconds plus microseconds since the epoch | 1136214245.123456 | string, int64[1], float64 |
s.ns | Seconds plus nanoseconds since the epoch | 1136214245.123456789 | string, int64[1], float64[2] |
- [1]Interpreted as seconds. Equivalent to using s layout.
- [2]Due to floating point precision limitations, loss of up to 100ns may be expected.