[erlang-questions] Current time in milliseconds

Essien Ita Essien <>
Sun Dec 7 10:25:01 CET 2008


Ahmed Ali wrote:
> Hi,
> 
> I found now() function which returns {MegaSecs, Secs, Microsecs}. Now
> the next question is what is MegaSecs? and is Microsecs value is the
> number of microseconds in this second or is it also since zero hour
> (00:00 GMT, January 1, 1970)?

You're correct, erlang:now() calculates the time from the epoch (00:00 
GMT, January 1, 1970).

The result {Megasecs, Secs, Microsecs} is just a fractional 
representation for convenience, and can be converted to seconds by:

SecondsSinceEpoch = (Megasecs * 1000000) + Secs + (Microsecs / 1000000)

Hope that helps.

cheers,
Essien

> 
> Best regards,
> Ahmed
> 
> On Sat, Dec 6, 2008 at 6:31 PM, Ahmed Ali <> wrote:
>> Hi List,
>>
>> I'd like to get the current time in milliseconds. I've been looking
>> around but couldn't find a way to do this in Erlang. Can anyone please
>> help?
>>
>> Best regards,
>>
>> Ahmed
>>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list