This is a creation in Article, where the information may have evolved or changed.
Most of the content here is collated from others.
http://my.oschina.net/1123581321/blog/190942
Timestamp current timestamp FMT. Println (time. Now (). Unix ()) # 1389058332
STR format time is currently formatted in FMT. Println (time. Now (). Format ("2006-01-02 15:04:05")) # This is a wonderful, must be this time point, said to be the day of the birth of Go, memory method: 6-1-2-3-4-5# 2014-01-07 09:42:20
Timestamp to STR format time str_time: = time. Unix (1389058332, 0). Format ("2006-01-02 15:04:05") fmt. Println (str_time) # 2014-01-07 09:32:12
STR format time-to-timestamp this is more troublesome the_time: = time. Date (1, 7, 5, 4, 0, time). Local) Unix_time: = The_time. Unix () fmt. Println (unix_time) # 389045004
There is also a way to use time. Parsethe_time, err: = time. Parse ("2006-01-02 15:04:05", "2014-01-08 09:04:41") if Err = = Nil { Unix_time: = the_time. Unix () FMT. Println (unix_time) }# 1389171881
Golang Programming Time Programming Http://blog.chinaunix.net/uid-24774106-id-4006530.html This article is very good, it's worth reading.