Skip to content

Instantly share code, notes, and snippets.

@arindamroynitw
Created June 17, 2020 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arindamroynitw/78885588175e55d706e60daf57ded55e to your computer and use it in GitHub Desktop.
Save arindamroynitw/78885588175e55d706e60daf57ded55e to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now()
formatted := t.Format(time.RFC1123)
fmt.Printf("Raw time variable is %v, formatted to RFC1123 is %v \n", t, formatted)
parsedTime, err := time.Parse(time.RFC1123, formatted)
if err != nil {
fmt.Printf("error in parsing time is %v", err)
} else {
fmt.Printf("Input string provided is %v and time variable generated is %v", formatted, parsedTime)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment