Skip to content

Instantly share code, notes, and snippets.

@dermesser
Created February 13, 2012 17:07
Show Gist options
  • Save dermesser/1818344 to your computer and use it in GitHub Desktop.
Save dermesser/1818344 to your computer and use it in GitHub Desktop.
Use of localtime()
# include <stdio.h>
# include <time.h>
# include <locale.h>
int main(void)
{
time_t currtime = time(NULL); // time_t time(time_t *timep)
struct tm *local, *gmt;
local = localtime(&currtime);
printf("Current local time: %02i:%02i:%02i %02i.%02i.%i\n",local->tm_hour,local->tm_min,local->tm_sec,local->tm_mday,local->tm_mon + 1,local->tm_year + 1900);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment