The most common advice is wrong, you can't just rely on time()
. That's used for relative timing: ISO C++ doesn't specify that 1970-01-01T00:00Z
is time_t(0)
What's worse is that you can't easily figure it out, either. Sure, you can find the calendar date of time_t(0)
with gmtime
, but what are you going to do if that's 2000-01-01T00:00Z
? How many seconds were there between 1970-01-01T00:00Z
and 2000-01-01T00:00Z
? It's certainly no multiple of 60, due to leap seconds.