Created
August 25, 2013 00:19
-
-
Save kelseyhightower/6331146 to your computer and use it in GitHub Desktop.
time to string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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