Standard library / net/http
http.ParseTime()
Parse HTTP date formats; return an error for invalid text. Expected stdout: '2006\n'.
Formal Syntax & Structure
go syntaxgo
func ParseTime(text string) (t time.Time, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| text | string | Text encoding of the address, endpoint or prefix. |
Return Value
(t time.Time, err error)
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/http")
func main() { t := must(http.ParseTime("Mon, 02 Jan 2006 15:04:05 GMT")); fmt.Println(t.Year()) }
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}