如何在erlang中将datetime()转换为timestamp() [英] How to convert datetime() to timestamp() in erlang
本文介绍了如何在erlang中将datetime()转换为timestamp()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将{{2012,9,21},{13,21,11}}转换为timestamp()。我怎样才能做到这一点?
谢谢。
I need to convert {{2012, 9, 21}, {13, 21, 11}} into timestamp(). How can I do that? Thank you.
推荐答案
更正版本:
Seconds = calendar:datetime_to_gregorian_seconds(DateTime) - 62167219200,
%% 62167219200 == calendar:datetime_to_gregorian_seconds({{1970, 1, 1}, {0, 0, 0}})
{Seconds div 1000000, Seconds rem 1000000, 0}.
这篇关于如何在erlang中将datetime()转换为timestamp()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文