[erlang-questions] Unix Epoch

Roberto Ostinelli roberto@REDACTED
Sun May 2 15:38:05 CEST 2010


i would suggest:

unix_time() ->
	{M, S, _} = now(),
	M*1000000 + S.

r.

2010/5/2 Henning Diedrich <hd2010@REDACTED>:
> Hi,
>
> is there a better way to turn datetime into unix epoch seconds?
>
> unix_time({Date,Time}) ->
>
>   UnixEpoch = {{1970,1,1},{0,0,0}},
>   calendar:datetime_to_gregorian_seconds({Date,Time}) -
> calendar:datetime_to_gregorian_seconds(UnixEpoch).
>
> Gregorian seconds down to year 0 might be a costly calculation I though.
>
> Thanks!
> Henning
>



-- 
-------------------------------------------------------------------
Roberto Ostinelli
CTO, WideTag Inc. - Realtime, Social, Green
widetag.com
skype: rostinelli
twitter: ostinelli
mobile: +39 335 6 100 22 6


More information about the erlang-questions mailing list