V
V
Vyacheslav2018-01-22 20:34:18
go
Vyacheslav, 2018-01-22 20:34:18

What are the ways to parse the date "Mon, 22 Jan 2018 19:21:00 +0300"?

I try this way:

t, err := time.Parse(time.RFC822Z, "Mon, 22 Jan 2018 19:21:00 +0300")

In response I get:
parsing time "Mon, 22 Jan 2018 19:21:00 +0300" as "02 Jan 06 15:04 -0700": cannot parse "Mon, 22 Jan 2018 19:21:00 +0300" as "02"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2018-01-22
@Firik67

You have a string in a different format. Try time.RFC1123Z.

K
kzoper, 2018-01-22
@kzoper

package main

import (
  "fmt"
  "log"
  "time"
)

func main() {
  x_time := "Mon, 22 Jan 2018 19:21:00 +0300"
  t, err := time.Parse("Mon, 02 Jan 2006 15:04:05 -0700", x_time)

  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(t)
}

playground

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question