Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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:%02d
", ptm->tm_hour, 
           ptm->tm_min, ptm->tm_sec);

    return 0;
}
Source by zetcode.com #
 
PREVIOUS NEXT
Tagged: #function #converts #current #time #timezone
ADD COMMENT
Topic
Name
8+8 =