#include <stdio.h>
      #include <time.h>
      #include <sys/time.h>
      
      void getLocalTime(time_t sec){
        printf("GetDateTime3:\t");
        char timeStr[20] = {0};
        struct tm *dateTime = localtime(&sec);
        sprintf(timeStr, "%d-%02d-%02d %02d:%02d:%02d",
                dateTime->tm_year + 1900,
                dateTime->tm_mon + 1,
                dateTime->tm_mday,
                dateTime->tm_hour,
                dateTime->tm_min,
                dateTime->tm_sec);
        printf("%s\n", timeStr);
      }
      
      C language logo

      Get local time

      Codiga's C Recipes

      Get local time in ISO format

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.