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.
Asked
Active
Viewed 8,426 times
1
-
I think he means the "number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time." – Jacob Jul 09 '10 at 20:09
-
Could you give us an example of the epoch? – Jacob Jul 09 '10 at 20:11
-
"epoch" represents a time reference, not an arbitrary time. http://en.wikipedia.org/wiki/Unix_time – Jason S Jul 09 '10 at 20:20
-
1@jason, that may be the dictionary definition but it doesn't seem to be the way queandans is using the term. – Mark Ransom Jul 09 '10 at 22:32
1 Answers
3
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
- 34,255
- 14
- 110
- 165
-
100: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 Jul 09 '10 at 20:21