Standard library / time

time.Time.UnmarshalText()

Parse an RFC3339 text timestamp without surrounding JSON quotes into the receiver. Expected stdout: '2024-02-29\n'.

Formal Syntax & Structure

go syntaxgo
func (t *Time) UnmarshalText(data []byte) error

Parameters & Attributes

NameTypeDescription
data[]byteEncoded bytes to decode.

Return Value

error

Parse an RFC3339 text timestamp without surrounding JSON quotes into the receiver.

Working Example

Example Snippetgo
package main
import (  "fmt"  "time")
func must(err error) {  if err != nil {    panic(err)  }}func main() {  var t time.Time  must(t.UnmarshalText([]byte("2024-02-29T12:00:00Z")))  fmt.Println(t.Format(time.DateOnly))}
Go Reference