How to use the gmtime() function in C

1 Answer

0 votes
#include <stdio.h>
#include <time.h>

// struct tm *gmtime(const time_t *timer) fill the tm structure

int main() {
    time_t now;

    time(&now);

    struct tm* t = gmtime(&now);
    
    printf("Universal Time: %2d:%02d\n", t->tm_hour % 24, t->tm_min);

    return 0;
}




/*
run:

Universal Time: 15:09

*/

 



answered Jan 8, 2023 by avibootz
...