gpt4 book ai didi

date - 在erlang中将时间戳转换为日期时间

转载 作者:行者123 更新时间:2023-12-03 10:59:52 26 4
gpt4 key购买 nike

如何在 Erlang 中将时间戳(自 1970 年 1 月 1 日以来的毫秒数...,又名纪元)转换为日期或日期时间格式?类似 {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.

关于date - 在erlang中将时间戳转换为日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/825151/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com