I've been stuck on converting from an integer epoch time value to a local time.
I currently have the time since epoch stored in an integer variable, and I need a way to convert that to local time.
I have tried passing it into localtime but it doesn't seem to work.
I can get localtime to work if I simply call
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
And get the rawtime directly, but I'm stuck if I want to give localtime() an integer value instead of just the current time.
The
localtime()
function takes a pointer toconst time_t
so you have to first convert your integer epoch value to atime_t
before callinglocaltime
.