Minute, Hour, Day, Month, Year

Learn about the Minute, Hour, Day, Month, Year OTTL converter function.

The Minute, Hour, Day, Month and Year converters each extract an int64 value from a time.Time type timestamp. These are different to the converters such as Hours, Microseconds, Milliseconds, Minutes, Nanoseconds and Seconds, which return a value from a time.Duration type.

Syntax: Minute|Hour|Day|Month|Year(value)

  • value is a date in the time.Time format. Other formats cause it to fail.

Note: the timestamp field in Edge Delta is a UnixMilli int64 format, not time.Time. See Manage Log Timestamps for timestamp handling and the Parse Timestamp Processor for parsing various timestamp formats.

Input

{
	"_type": "log",
	"body": "High throughput observed. Device performance logged.",
	"resource": {...},
	"timestamp": 1733742090432
}

Statement

set(attributes["date_time"], Format("%04d-%02d-%02d %02dh%02d UTC", [Year(Now()), Month(Now()), Day(Now()), Hour(Now()), Minute(Now())]))

See Format and Now.

Output

{
	"_type": "log",
	"attributes": {
		"date_time": "2024-12-09 11h01 UTC"
	},
	"body": "High throughput observed. Device performance logged.",
	"resource": {...},
	"timestamp": 1733742076089
}

A new timestamp was created using Now functions and formatted using the Format function.