当前位置:网站首页>The difference of time zone and the time library of go language
The difference of time zone and the time library of go language
2022-07-05 23:52:00 【I'm PY】
UTC,GMT,CST What is it? ?
- You can refer to this article :https://baijiahao.baidu.com/s?id=1732139602203523267
- UTC Time is slower than the time zone indicated by Shanghai, China 8 Hours .
- CST: 2022-08-22 00:00:00 +0800 CST
- UTC: 2022-08-21 16:00:00 +0000 UTC
Go In language time Some common methods of Library
time.Local (*time.Location): Get the time zone of the current system
time.UTC (*time.Location): UTC
func time.Parse(layout string, value string) (time.Time, error)
- You can convert a string to go Time type . first layout Is the corresponding time template . time Many templates are built in the Library . You can customize FormatTimeShort = “2006-01-02”, The template can only be parsed to date .
- The default conversion time of this method is UTC Time .
func time.ParseInLocation(layout string, value string, loc *time.Location) (time.Time, error)
- This method can pass time zone information when parsing .
func time.Now() time.Time
return Current time zone Time for .func (time.Time).UTC() time.Time
Time that will have a time zone , Turn into UTC Time represented .func (time.Time).Unix() int64
This method will Time Type of time converted to Time stamp , Timestamp is time independent . The default is UTC The start of the specified time .func time.Unix(sec int64, nsec int64) time.Time
This function can convert the timestamp into Current time zone Of Time Type time .func (time.Time).MarshalJSON() ([]byte, error)
It's time to analyze json Function of format .
Be careful :
- When using time , Pay attention to the conversion of time zones .
- Generally, when reading the local time zone , Pay attention to the setting of the local time zone :
- such as ubuntu System , Input
date
Instructions , You can get the current time . timedatectl set-timezone Asia/Shanghai
Set the current time zone to Time zone in Shanghai, China .
- such as ubuntu System , Input
边栏推荐
- 20220703 周赛:知道秘密的人数-动规(题解)
- Breadth first search open turntable lock
- 保研笔记二 软件工程与计算卷二(13-16章)
- Initialiser votre vecteur & initialisateur avec une liste Introduction à la Liste
- Hcip course notes-16 VLAN, three-tier architecture, MPLS virtual private line configuration
- Convert Chinese into pinyin
- 【SQL】各主流数据库sql拓展语言(T-SQL 、 PL/SQL、PL/PGSQL)
- Russian Foreign Ministry: Japan and South Korea's participation in the NATO summit affects security and stability in Asia
- CAS and synchronized knowledge
- Rsync remote synchronization
猜你喜欢
用列表初始化你的vector&&initializer_list简介
Fiddler Everywhere 3.2.1 Crack
Rasa 3. X learning series -rasa 3.2.1 new release
18.(arcgis api for js篇)arcgis api for js点采集(SketchViewModel)
Rasa 3.x 学习系列-Rasa 3.2.1 新版本发布
C reflection and type
XML配置文件(DTD详细讲解)
98. Verify the binary search tree ●●
20220703 周赛:知道秘密的人数-动规(题解)
Huawei simulator ENSP - hcip - MPLS experiment
随机推荐
保研笔记二 软件工程与计算卷二(13-16章)
My colleagues quietly told me that flying Book notification can still play like this
云呐|固定资产管理系统功能包括哪些?
云呐|固定资产管理系统主要操作流程有哪些
MySQL delete uniqueness constraint unique
Objective C message dispatch mechanism
云呐|公司固定资产管理系统有哪些?
Spire Office 7.5.4 for NET
C # input how many cards are there in each of the four colors.
Zero rhino technology joined hands with the intelligence Club: the "causal faction" forum was successfully held, and the "causal revolution" brought the next generation of trusted AI
XML configuration file (DTD detailed explanation)
有什么不起眼却挣钱的副业?
Miaochai Weekly - 8
Switching power supply buck circuit CCM and DCM working mode
Rasa 3. X learning series -rasa x Community Edition (Free Edition) changes
15 MySQL-存储过程与函数
Latex multiple linebreaks
TS type declaration
Breadth first search open turntable lock
The use of El cascader and the solution of error reporting