https://github.com/joeshaw/iso8601
Go package for encoding time in JSON in ISO 8601 format
https://github.com/joeshaw/iso8601
golang iso8601 rfc-3339
Last synced: 2 months ago
JSON representation
Go package for encoding time in JSON in ISO 8601 format
- Host: GitHub
- URL: https://github.com/joeshaw/iso8601
- Owner: joeshaw
- License: mit
- Created: 2014-03-25T20:21:18.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-03-27T14:18:09.000Z (over 11 years ago)
- Last Synced: 2025-08-13T18:57:28.631Z (2 months ago)
- Topics: golang, iso8601, rfc-3339
- Language: Go
- Size: 117 KB
- Stars: 22
- Watchers: 3
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iso8601 #
iso8601 is a simple Go package for encoding `time.Time` in JSON in ISO
8601 format, without subsecond resolution or time zone info.```go
package mainimport (
"encoding/json"
"fmt"
"time""github.com/joeshaw/iso8601"
)func main() {
t := time.Now()// Standard JSON format
// "2014-03-25T16:15:25.701623113-04:00"
data, _ := json.Marshal(t)
fmt.Println(string(data))// ISO8601 JSON format
// "2014-03-25T16:15:25"
data, _ = json.Marshal(iso8601.Time(t))
fmt.Println(string(data))// Output after decoding back to go. Note the loss of
// precision and time zone info.
// 2014-03-25 16:15:25 +0000 +0000
var t2 iso8601.Time
json.Unmarshal(data, &t2)
fmt.Println(t2)
}
```