queandans
queandans

Reputation: 63

convert epoch to time_t

I have a epoch in double and need to pass in to a function that takes time_t. How do I convert the epoch in double to time_t? I am on Linux with C++ code. Thanks.

Upvotes: 1

Views: 9124

Answers (1)

Jacob
Jacob

Reputation: 34601

If you have the epoch in double, shouldn't this work?

time_t t = static_cast<time_t>(epoch_time);

Assuming you mean that the epoch is the

number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time.

Upvotes: 3

Related Questions