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.

queandans
  • 63
  • 2
  • 8

1 Answers1

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
  • 1
    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 Jul 09 '10 at 20:21