Number of seconds since January 1, 1970 00:00:00 GMT Erlang
You have to calculate the UNIX time (seconds since 1970) from the results of now()
, like this:
{MegaSecs, Secs, MicroSecs} = now().UnixTime = MegaSecs * 1000000 + Secs.
Just using the second entry of the tuple will tell you the time in seconds since the last decimal trillionellium (in seconds since the UNIX epoch).
[2017 Edit]now
is deprecated, but erlang:timestamp()
is not and returns the same format as now
did.
Which of these 3 parameters is the required number of seconds since Jan 1, 1970 ?
All three of them, collectively. Look at the given timestamp. It's January 7, 1970. Presumably Secs
will be between 0 (inclusive) and 1,000,000 (exclusive). One million seconds is only 11.574 days. You need to use the megaseconds as well as the seconds. Since the error tolerance is 600 seconds you can ignore the microseconds part of the response from erlang:now()
.