Skip to content

Instantly share code, notes, and snippets.

@fatso83
Last active December 23, 2021 01:08
Show Gist options
  • Save fatso83/86e94e91926d1311f3fa to your computer and use it in GitHub Desktop.
Save fatso83/86e94e91926d1311f3fa to your computer and use it in GitHub Desktop.
Print the number of millis since the Epoch (Jan 1 1970)
/**
* Print the number of millis since the Epoch (Jan 1 1970)
* Compile: cc millis.cc -o millis
* Put in your path: mv millis /usr/local/bin
*/
#include <stdio.h>
#include <sys/time.h>
int main(void)
{
struct timeval time_now;
gettimeofday(&time_now,NULL);
printf ("%ld%03d\n",time_now.tv_sec,time_now.tv_usec/1000);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment