[erlang-questions] Unix Epoch
Rapsey
rapsey@REDACTED
Sun May 2 15:45:53 CEST 2010
Epoch seconds from 0 is a constant. So no need to calculate it every time.
Sergej
On Sun, May 2, 2010 at 3:33 PM, Henning Diedrich <hd2010@REDACTED>wrote:
> 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
>
More information about the erlang-questions
mailing list