Standard library / log/slog
slog.Time()
Construct a keyed Time attribute for structured logging. Expected stdout: 'key\n1970-01-01 00:00:00 +0000 UTC\n'.
Formal Syntax & Structure
go syntaxgo
func Time(key string, v time.Time) AttrParameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | string | Attribute key. |
| v | time.Time | Values to log or convert. |
Return Value
Attr
Construct a keyed Time attribute for structured logging.
Working Example
Example Snippetgo
package main
import ( "fmt" "log/slog" "time")
func main() { a := slog.Time("key", time.Unix(0, 0).UTC()); fmt.Println(a.Key); fmt.Println(a.Value) }