当前位置:网站首页>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
边栏推荐
- Bao Yan notebook IV software engineering and calculation volume II (Chapter 8-12)
- 【GYM 102832H】【模板】Combination Lock(二分图博弈)
- 妙才周刊 - 8
- 14 MySQL-视图
- Do you regret becoming a programmer?
- 成为程序员的你,后悔了吗?
- C# 文件与文件夹操作
- The use of El cascader and the solution of error reporting
- 20220703 周赛:知道秘密的人数-动规(题解)
- Asynchronous task Whenall timeout - Async task WhenAll with timeout
猜你喜欢
Rsync remote synchronization
Problem solving win10 quickly open ipynb file
My colleagues quietly told me that flying Book notification can still play like this
PV static creation and dynamic creation
XML configuration file (DTD detailed explanation)
Spire.PDF for NET 8.7.2
PV静态创建和动态创建
20220703 week race: number of people who know the secret - dynamic rules (problem solution)
传输层协议------UDP协议
21.PWM应用编程
随机推荐
21.PWM应用编程
云呐|固定资产管理系统功能包括哪些?
【GYM 102832H】【模板】Combination Lock(二分图博弈)
How to get all the values stored in localstorage
Go language introduction detailed tutorial (I): go language in the era
Initialiser votre vecteur & initialisateur avec une liste Introduction à la Liste
云呐|公司固定资产管理系统有哪些?
18.(arcgis api for js篇)arcgis api for js点采集(SketchViewModel)
【SQL】各主流数据库sql拓展语言(T-SQL 、 PL/SQL、PL/PGSQL)
Rasa 3.x 学习系列-Rasa 3.2.1 新版本发布
【luogu P3295】萌萌哒(并查集)(倍增)
Bao Yan notes II software engineering and calculation volume II (Chapter 13-16)
Do you regret becoming a programmer?
20220703 周赛:知道秘密的人数-动规(题解)
My colleagues quietly told me that flying Book notification can still play like this
Spire. PDF for NET 8.7.2
Spire Office 7.5.4 for NET
教你在HbuilderX上使用模拟器运行uni-app,良心教学!!!
MySQL delete uniqueness constraint unique
424. The longest repeated character after replacement ●●