当前位置:网站首页>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
边栏推荐
- 妙才周刊 - 8
- 保研笔记一 软件工程与计算卷二(1-7章)
- How to improve eloquence
- MySQL delete uniqueness constraint unique
- Do you regret becoming a programmer?
- 同事悄悄告诉我,飞书通知还能这样玩
- rsync远程同步
- Make a short video clip number of we media film and television. Where can I download the material?
- Initialiser votre vecteur & initialisateur avec une liste Introduction à la Liste
- 21.PWM应用编程
猜你喜欢
保研笔记四 软件工程与计算卷二(8-12章)
PV静态创建和动态创建
Rasa 3. X learning series -rasa x Community Edition (Free Edition) changes
Bao Yan notebook IV software engineering and calculation volume II (Chapter 8-12)
Rsync remote synchronization
XML configuration file (DTD detailed explanation)
Initialize your vector & initializer with a list_ List introduction
98. Verify the binary search tree ●●
C# 反射与Type
云呐|公司固定资产管理系统有哪些?
随机推荐
SpreadJS 15.1 CN 与 SpreadJS 15.1 EN
Fiddler Everywhere 3.2.1 Crack
Qt 一个简单的word文档编辑器
【SQL】各主流数据库sql拓展语言(T-SQL 、 PL/SQL、PL/PGSQL)
CloudCompare&PCL 点云随机添加噪声
【GYM 102832H】【模板】Combination Lock(二分图博弈)
Naoqi robot summary 26
开源crm客户关系统管理系统源码,免费分享
Go language introduction detailed tutorial (I): go language in the era
[gym 102832h] [template] combination lock (bipartite game)
[Luogu cf487e] tours (square tree) (tree chain dissection) (line segment tree)
USB Interface USB protocol
Miaochai Weekly - 8
数据库遇到的问题
GFS分布式文件系統
软件测试工程师必会的银行存款业务,你了解多少?
20.移植Freetype字体库
Why use weak pointers for delegation- Why use weak pointer for delegation?
Fiddler Everywhere 3.2.1 Crack
GFS Distributed File System