Gmtime Function

  • It is used for returning time as Coordinated Universal Time (mainly GMT , Greenwhich Mean Time) .

    Syntax:

     struct tm *gmtime(const time_t *time);
    
    

    Example:

    
    #include <time.h>
    
      #include <stdio.h>
    
      int main()
    
      {
    
        struct tm *local_time, *greenwhich_time;
    
        time_t t;
    
        t = time(NULL);
    
        local_time = localtime(&t);
    
        printf("Local time and date: %s\n", asctime(local_time));
    
        greenwhich_time = gmtime(&t);
    
        printf("Coordinated Universal Time and date: %s", asctime(greenwhich_time));
    
        return 0;
    
      }  
    Back