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.

ExpressionDescription
%YYear, zero-padded (0001, 0002, ..., 2019, 2020, ..., 9999)
%yYear, last two digits, zero-padded (01, ..., 99)
%mMonth as a decimal number (01, 02, ..., 12)
%oMonth as a space-padded number (1, 2, ..., 12)
%qMonth as an unpadded number (1,2,...,12)
%b, %hAbbreviated month name (Jan, Feb, ...)
%BFull month name (January, February, ...)
%dDay of the month, zero-padded (01, 02, ..., 31)
%eDay of the month, space-padded (1, 2, ..., 31)
%gDay of the month, unpadded (1,2,...,31)
%aAbbreviated weekday name (Sun, Mon, ...)
%AFull weekday name (Sunday, Monday, ...)
%HHour (24-hour clock) as a zero-padded decimal number (00, ..., 24)
%IHour (12-hour clock) as a zero-padded decimal number (00, ..., 12)
%pLocale’s equivalent of either AM or PM
%PLocale’s equivalent of either am or pm
%MMinute, zero-padded (00, 01, ..., 59)
%SSecond as a zero-padded decimal number (00, 01, ..., 59)
%LMillisecond as a decimal number, zero-padded on the left (000, 001, ..., 999)
%fMicrosecond as a decimal number, zero-padded on the left (000000, ..., 999999)
%sNanosecond as a decimal number, zero-padded on the left (000000, ..., 999999)
%zUTC offset in the form ±HHMM[SS[.ffffff]] or empty(+0000, -0400)
%ZTimezone name or abbreviation or empty (UTC, EST, CST)
%D, %xShort MM/DD/YY date, equivalent to %m/%d/%y
%FShort YYYY-MM-DD date, equivalent to %Y-%m-%d
%T, %XISO 8601 time format (HH:MM:SS), equivalent to %H:%M:%S
%r12-hour clock time (02:55:02 pm)
%R24-hour HH:MM time, equivalent to %H:%M
%nNew-line character ('\n')
%tHorizontal-tab character ('\t')
%%A % sign
%cDate 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.

LayoutMeaningExampleData Type Support
sSeconds since the epoch1136214245string, int64, float64
msMilliseconds since the epoch1136214245123string, int64, float64
usMicroseconds since the epoch1136214245123456string, int64, float64
nsNanoseconds since the epoch1136214245123456789string, int64, float64[2]
s.msSeconds plus milliseconds since the epoch1136214245.123string, int64[1], float64
s.usSeconds plus microseconds since the epoch1136214245.123456string, int64[1], float64
s.nsSeconds plus nanoseconds since the epoch1136214245.123456789string, 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.