I’ve been reading Richard Bejtlich’s Tao of Network Security Monitoring for one of my classes at school. I came across the date -r command Richard was using to translate UNIX epoch times to a readable time format. The date command that shipped with my distribution of Linux does not support the -r flag, so I am sharing this very simple program for anyone who is interested.


#include <stdio.h>
#include <time.h>
void main(int argc, char **argv)
{
time_t t = atoi(argv[1]);
printf("%s\n",ctime(&t));
}

To compile and use this program, do the following steps:

$ gcc -o time_t time_t.c
$ chmod +x time_t
Usage: ./time_t <time>