Go Set time zone

Source: Internet
Author: User
Tags set time
This is a created article in which the information may have evolved or changed. Time package to set the TimeZone method: "' l,_: =. Loadlocation ("Asia/shanghai") fmt. Println (time. Now (). In (l)) L,_ = time. Loadlocation ("America/adak") fmt. Println (time. Now (). In (L)) "The loadlocation has a problem, it relies on the IANA Time Zone database (abbreviated as Tzdata Bar), the general Linux system is brought, but the Windows system is not brought. No tzdata will be found from the $goroot/. There is no way to set the time zone through ' loadlocation ' for Windows systems that do not have a go environment installed. But there are ways, we can put the Tzdata file in our own program directory, and then let the time package can be loaded from our own program directory to load the timezone file. The file directory can be set through the environment variable, in the Main method: ' OS. Setenv ("Zoneinfo", '/home/tz/data.zip ') ' and then the Loadlocation method is OK. Data.zip file I uploaded to GitHub and downloaded directly. You can also try making your own ~ Download Portal: [Https://github.com/keepeye/tzdata] (https://github.com/keepeye/tzdata) 244 reads
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.