Getting system start time in UTC?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting system start time in UTC?

Roger Lipscombe-2
I can get the node's uptime with erlang:statistics(wall_clock), which
is in milliseconds, and can easily be converted into days, hours, etc.
representing how long this node has been up.

Is there an easy way to get the start time of the node, represented as
a UTC date/time? I'd like to be able to print "Up since dd/MM/yyyy (D
days ...", etc.

Obviously, I *could* subtract the uptime from the current date/time,
but that seems more complicated than necessary, assuming the node has
(somewhere) the actual start time.

Thanks,
Roger.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Getting system start time in UTC?

Danil Zagoskin-2
Hi!

Maybe erlang:system_info(start_time) is what are you looking for.

Get Unix time at system start:
erlang:convert_time_unit(erlang:system_info(start_time) + erlang:time_offset(), native, seconds).

On Mon, Oct 23, 2017 at 2:05 PM, Roger Lipscombe <[hidden email]> wrote:
I can get the node's uptime with erlang:statistics(wall_clock), which
is in milliseconds, and can easily be converted into days, hours, etc.
representing how long this node has been up.

Is there an easy way to get the start time of the node, represented as
a UTC date/time? I'd like to be able to print "Up since dd/MM/yyyy (D
days ...", etc.

Obviously, I *could* subtract the uptime from the current date/time,
but that seems more complicated than necessary, assuming the node has
(somewhere) the actual start time.

Thanks,
Roger.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



--
Danil Zagoskin | [hidden email]

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions