Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

DolphinDB中本地时间和UTC时间如何实现快速转换

DolphinDB中有没有本地时间和UTC时间之间快速转换的内置函数?比如,现有的时间是本地时间,我想把他转换成UTC时间;现有的时间是UTC时间,我想把它转换成本地时间。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

可以使用localtime()函数和gmtime()函数;
localtime(X)是把零时区时间X转换成本地时间;
gmtime(X)是把本地时间X转换成零时区时间,即格林尼治时间(GMT)。
示例代码:

localtime(2018.01.22 15:20:26)
localtime(2017.12.16T18:30:10.001)
gmtime(2018.01.22 10:20:26)
gmtime(2017.12.16T13:30:10.008)

返回结果:

2018.01.22T23:20:26
2017.12.17T02:30:10.001
2018.01.22T02:20:26
2017.12.16T05:30:10.008

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...