Golang Time Operation Finishing

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.