tags:

views:

65

answers:

1

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.

+1  A: 

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.

Jacob
00:00:00 Jan 1 1970 UCT *is* the UNIX epoch, which is a fixed reference instant in time. The number of seconds *since* the epoch is a time and is not itself an epoch.
Jason S