Mega Code Archive

 
Categories / C / Development
 

Create local time from time()

#include <time.h> #include <stdio.h> int main(void) {   struct tm *ptr;   time_t lt;   char str[80];   lt = time(NULL);   ptr = localtime(&lt);   strftime(str, 100, "It is now %H %p.", ptr);   printf(str);   return 0; }