Skip to content

time: RFC3339 only parses the subset of valid RFC3339 datetimes where T is used to separate the date & time #76823

@hadmut

Description

@hadmut

Go version

go version go1.24.4 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/hadmut/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/hadmut/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1507873698=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/hadmut/gotest/go.mod'
GOMODCACHE='/home/hadmut/go/pkg/mod'
GONOPROXY='*.danisch.de'
GONOSUMDB='*.danisch.de'
GOOS='linux'
GOPATH='/home/hadmut/go'
GOPRIVATE='*.danisch.de'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go-1.24'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/hadmut/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go-1.24/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.4'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Run this code:

package main

import (
	"fmt"
	"time"
)

func main() {
	t, err := time.Parse(time.RFC3339, "2025-12-13 22:44:41+02:00")
	if err != nil {
		panic(err.Error())
	}
	fmt.Println(t)
}

(playground)

What did you see happen?

panic: parsing time "2025-12-13 22:44:41+02:00" as "2006-01-02T15:04:05Z07:00": cannot parse " 22:44:41+02:00" as "T"

goroutine 1 [running]:
main.main()
	/tmp/sandbox1968158324/prog.go:11 +0xac

Program exited.

What did you expect to see?

2025-12-13 22:44:41 +0200 +0200

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a tool

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions