Golang get 0 points of the day

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Recently encountered a small problem in the project, need to get the date of the day 0 time, with Golang implementation, review the relevant data implementation methods are as follows:

Package Main

Import (
"FMT"
"Time"
)

Get 0 points on the day
Func Main () {
TIMESTR: = time. Now (). Format ("2006-01-02")
Fmt. Println ("Timestr:", Timestr)
T, _: = time. Parse ("2006-01-02", Timestr)
Timenumber: = T.unix ()
Fmt. Println ("Timenumber:", Timenumber)
}


The results of the operation are as follows:



It is worth mentioning that the value of the Timenumber timestamp is not 0, but 8:00 of the time of the morning.

Therefore, it is necessary to subtract the time stamp value of eight hours on this basis for the 0 point of the day.

So the corresponding 0-point timestamp for the day is 1469808000.

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.