从 erlang:system_time() 转换为 os:timestamp()
Convert from erlang:system_time() to os:timestamp()
如何将整数 erlang:system_time() 转换为 os:timestamp() {MegaSecs, Secs, MicroSecs}?
在Erlang中,我们可以用下面的代码进行转换:
timestamp() ->
ErlangSystemTime = erlang:system_time(microsecond),
MegaSecs = ErlangSystemTime div 1000000000000,
Secs = ErlangSystemTime div 1000000 - MegaSecs*1000000,
MicroSecs = ErlangSystemTime rem 1000000,
{MegaSecs, Secs, MicroSecs}
如何将整数 erlang:system_time() 转换为 os:timestamp() {MegaSecs, Secs, MicroSecs}?
在Erlang中,我们可以用下面的代码进行转换:
timestamp() ->
ErlangSystemTime = erlang:system_time(microsecond),
MegaSecs = ErlangSystemTime div 1000000000000,
Secs = ErlangSystemTime div 1000000 - MegaSecs*1000000,
MicroSecs = ErlangSystemTime rem 1000000,
{MegaSecs, Secs, MicroSecs}