Unix Epoch

Henning Diedrich hd2010@REDACTED
Sun May 2 15:33:41 CEST 2010


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