本文介绍了在erlang中将时间戳转换为datetime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将Erlang中的时间戳(1970年1月1日以来的毫秒数)转换为Date或DateTime格式?
How can I convert a timestamp (number of milliseconds since 1 Jan 1970...) to Date or DateTime format in Erlang? Something like {Year,Month,Day}.
推荐答案大致:
msToDate(Milliseconds) -> BaseDate = calendar:datetime_to_gregorian_seconds({{1970,1,1},{0,0,0}}), Seconds = BaseDate + (Milliseconds div 1000), { Date,_Time} = calendar:gregorian_seconds_to_datetime(Seconds), Date.更多推荐
在erlang中将时间戳转换为datetime
发布评论