Standard library / log/slog

slog.TimeValue()

Construct an unkeyed Time value for use in an attribute. Expected stdout: '1970-01-01 00:00:00 +0000 UTC\n'.

Formal Syntax & Structure

go syntaxgo
func TimeValue(v time.Time) Value

Parameters & Attributes

NameTypeDescription
vtime.TimeValues to log or convert.

Return Value

Value

Construct an unkeyed Time value for use in an attribute.

Working Example

Example Snippetgo
package main
import (  "fmt"  "log/slog"  "time")
func main() { fmt.Println(slog.TimeValue(time.Unix(0, 0).UTC())) }
Go Reference