I have time in epoch format.
I just want to retrieve Year from it.
how should we do it in c or c++ ?
Actually i have time since epoch in seconds and i need to calculate age depending on it.
So input will be seconds since epoch and out put should be Age based on current date.
Thanks,
PP.
In C timestamps (ie: seconds from epoch) are usually stored in
time_t, while human-wise dates are stored in structuretm. You need a function that convertstime_ts intms.gmtimeorlocaltimeare two C standard function that do your job.Warning that these functions are not thread-safe. You’ll find a reentrant version on POSIX systems (linux, mac os x, …):
gmtime_randlocaltime_r