Created
May 7, 2013 12:01
-
-
Save DimitryDushkin/5532071 to your computer and use it in GitHub Desktop.
Erlang get current time in milliseconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-spec get_timestamp() -> integer(). | |
get_timestamp() -> | |
{Mega, Sec, Micro} = os:timestamp(), | |
(Mega*1000000 + Sec)*1000 + round(Micro/1000). |
Elixir version of this in case anyone wants it.
defp system_time do
{mega, seconds, ms} = :os.timestamp()
(mega*1000000 + seconds)*1000 + :erlang.round(ms/1000)
end
If you are on Erlang 18 or newer, look into using :erlang.system_time
instead of this.
thanks
Thanks @joakimk . :erlang.system_time / 1.0e6 |> round
works to get the millis
there is Erlang function to get timestamp in ms :os.system_time(:millisecond)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!