Skip to content

Instantly share code, notes, and snippets.

@ncopa
Created June 23, 2014 09:36
Show Gist options
  • Save ncopa/68c6fd8471a5a2de706d to your computer and use it in GitHub Desktop.
Save ncopa/68c6fd8471a5a2de706d to your computer and use it in GitHub Desktop.
a1:~/1# cat a.c
/* localtime example */
#include <stdio.h> /* puts, printf */
#include <time.h> /* time_t, struct tm, time, localtime */
int main ()
{
time_t rawtime;
struct tm * timeinfo;
time (&rawtime);
timeinfo = localtime (&rawtime);
printf ("Current local time and date: %s", asctime(timeinfo));
return 0;
}
a1:~/1# ./a.out
Current local time and date: Mon Jun 23 11:36:34 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment