Use gmtime(3)or localtime(3)to convert it to struct tm
(Or, better, reentrant versions of gmtime_ror localtime_r), and then use strftime(3)to turn it into a string. For example, if you want to output in UTC format:
struct tm tm;
char buf[9];
gmtime_r(&my_time_t, &tm);
strftime(buf, sizeof(buf), "%Y%m%d", tm);
printf("The date is: %s\n", buf);
source
share