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) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| data | []byte | Encoded 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))}