Interface LogTimestamp

Source
Expand description

Represents a timestamp for a log entry. The timestamp is a Unix epoch time with nanosecond precision. The timestamp is generated when the LogTimestamp object is created. The timestamp is immutable. The timestamp is represented as a string in the format YYYY-MM-DDTHH:MM:SS.NNNNNNNNNZ.

interface LogTimestamp {
    nanos: number;
    seconds: number;
    toJSON(): { nanos: number; seconds: number };
    toString(): string;
}

Properties§

Source§

public readonly nanos: number

The number of nanoseconds since the Unix epoch.

Source§

public readonly seconds: number

The number of seconds since the Unix epoch.

Methods§

Source§

toJSON(): { nanos: number; seconds: number }

Returns a JSON representation of the timestamp.

Source§

toString(): string

Returns a string representation of the timestamp in RFC3339 UTC "Zulu" format.

Example:

const timestamp = new LogTimestamp();
console.log(timestamp.toString());
// Output: 2021-07-29T23:27:47.000000000Z