Skip to content

Instantly share code, notes, and snippets.

@kelseyhightower
Created August 25, 2013 00:19
Show Gist options
  • Save kelseyhightower/6331146 to your computer and use it in GitHub Desktop.
Save kelseyhightower/6331146 to your computer and use it in GitHub Desktop.
time to string
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now()
// The Time type implements the Stringer interface -- it
// has a String() method which gets called automatically by
// functions like Printf().
fmt.Printf("%s\n", t)
// See the Constants section for more formats
// http://golang.org/pkg/time/#Time.Format
formatedTime := t.Format(time.RFC1123)
fmt.Println(formatedTime)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment