Time and UnixMilli

Learn about the Time and UnixMilli OTTL converter function.

The Time Converter coverts a string into the time.Time type. This type is not used by Edge Delta. The timestamp field in Edge Delta is a UnixMilli int64 format so it needs to be converted further.

set(timestamp, UnixMilli(Time(attributes["timestamp"], "%Y-%m-%dT%H:%M:%SZ")))

This node converts the extracted timestamp into a standardized Unix Millisecond format as follows:

  • set: This function is used to assign a value to the timestamp field.
  • attributes["timestamp"]: This is accessing a value that is stored in the attributes map with the key timestamp.
  • Time: This function converts a string representation of a time to a time.Time object. The format used here is %Y-%m-%dT%H:%M:%SZ, which corresponds to the ISO 8601 standard format for representing date and time (e.g., 2023-01-01T00:00:00Z). See the list of substitutions here.
  • UnixMilli: This function converts a time.Time object into a Unix time.

For comprehensive timestamp management in Edge Delta, see: