Skip to content

Instantly share code, notes, and snippets.

@yoggy
Created October 5, 2010 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoggy/611432 to your computer and use it in GitHub Desktop.
Save yoggy/611432 to your computer and use it in GitHub Desktop.
// gcc -o test test.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
int i;
time_t t;
struct tm *tmp;
char datestr[256];
for (;;) {
t = time(NULL);
tmp = localtime(&t);
strftime(datestr, sizeof(datestr), "%Y/%m/%d %H:%M:%S", tmp);
printf("date: %s\n", datestr);
sleep(1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment