Answers for "function in c that converts current time in timezone"

0

function in c that converts current time in timezone

#include <stdio.h> 
#include <time.h>       
 
int main(void) {
    
    time_t rawtime = time(NULL);
    
    if (rawtime == -1) {
        
        puts("The time() function failed");
        return 1;
    }
    
    struct tm *ptm = localtime(&rawtime);
    
    if (ptm == NULL) {
        
        puts("The localtime() function failed");
        return 1;
    }
    
    printf("The time is: %02d:%02d:%02dn", ptm->tm_hour, 
           ptm->tm_min, ptm->tm_sec);

    return 0;
}
Posted by: Guest on January-29-2022

Code answers related to "function in c that converts current time in timezone"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language