gmtime() Function in C Last Updated : 06 Oct, 2023 Comments Improve Suggest changes Like Article Like Report The gmtime() function in C takes a pointer to type t_time value which represents type in seconds and converts it to struct tm. In this article, we will learn gmtime() Function in the C programming language. The struct tm type can hold the individual components of time in UTC(Universal Time Coordinated) or GMT time (i.e., the time in the GMT timezone) time zones. The C gmtime() function is defined in <ctime> header file. Syntax of gmtime()tm* gmtime ( const time_t* current_time )The hours can be accessed using tm_hourThe minutes can be accessed using tm_minThe seconds can be accessed using tm_secParameterscurrent_time: It specifies a pointer to a time_t object.Return ValueOn Success, returns a pointer to a tm object.Otherwise, the Null pointer is returned.Examples of gmtime()Example 1 C // C program to illustrate the gmtime() function #include <stdio.h> #include <time.h> #define CST (+8) #define IND (-5) int main() { // object time_t current_time; // pointer struct tm* ptime; // use time function time(¤t_time); // gets the current-time ptime = gmtime(¤t_time); // print the current time printf("Current time:\n"); printf("Beijing ( China ):%2d:%02d:%02d\n", (ptime->tm_hour + CST) % 24, ptime->tm_min, ptime->tm_sec); printf("Delhi ( India ):%2d:%02d:%02d\n", (ptime->tm_hour + IND) % 24, ptime->tm_min, ptime->tm_sec); return 0; } OutputCurrent time: Beijing ( China ):20:00:04 Delhi ( India ): 7:00:04Example 2 C // C++ program to illustrate the // gmtime() function #include <stdio.h> #include <time.h> #define UTC (0) #define ART (-3) int main() { // object time_t current_time; // pointer struct tm* ptime; // use time function time(¤t_time); // print the current time ptime = gmtime(¤t_time); printf("Current time:\n"); printf("Monrovia ( Liberia ) :%2d:%02d:%02d\n", (ptime->tm_hour + UTC) % 24, ptime->tm_min, ptime->tm_sec); printf("Buenos Aires ( Argentina ) :%2d:%02d:%02d\n", (ptime->tm_hour + ART) % 24, ptime->tm_min, ptime->tm_sec); return 0; } OutputCurrent time: Monrovia ( Liberia ) :11:45:36 Buenos Aires ( Argentina ) : 8:45:36 Comment More infoAdvertise with us Next Article gmtime() Function in C A AmanSrivastava1 Follow Improve Article Tags : C Language CPP-Functions C-Library Similar Reads getx() function in C The header file graphics.h contains getx() function which returns the X coordinate of the current position. Syntax : int getx(); Example : Explanation : Initially, the X coordinate of the current position is 0. On moving the coordinates using moveto() function, the X coordinate changes to 80. Below 2 min read gety() function in C The header file graphics.h contains gety() function which returns the Y coordinate of the current position. Syntax : int gety(); Example : Explanation : Initially, the Y coordinate of the current position is 0. On moving the coordinates using moveto() function, the Y coordinate changes to 50. Below 2 min read main Function in C The main function is the entry point of a C program. It is a user-defined function where the execution of a program starts. Every C program must contain, and its return value typically indicates the success or failure of the program. In this article, we will learn more about the main function in C.E 5 min read imagesize() function in C The header file graphics.h contains imagesize() function which returns the number of bytes required to store a bit-image. Syntax : unsigned int imagesize(int left, int top, int right, int bottom); where, left, top, right, and bottom define the area of the screen in which image is stored. Below is th 2 min read lineto() function in C The header file graphics.h contains lineto() function which draws a line from current position to the point(x,y). Note : Use getx() and gety() to get the current position. Syntax : lineto(int x, int y); where, (x, y) are the coordinates upto which the line will be drawn from previous point. CASE 1 : 2 min read C String Functions C language provides various built-in functions that can be used for various operations and manipulations on strings. These string functions make it easier to perform tasks such as string copy, concatenation, comparison, length, etc. The <string.h> header file contains these string functions.Th 6 min read Function Pointer in C In C, a function pointer is a type of pointer that stores the address of a function, allowing functions to be passed as arguments and invoked dynamically. It is useful in techniques such as callback functions, event-driven programs, and polymorphism (a concept where a function or operator behaves di 6 min read round() Function in C In the C language, the <math.h> header file contains the Standard Math Library that provides various mathematical functions, including the round() function. In this article, we will see how to use the round() function in C.What is round() in C?C round() is a built-in library function that roun 3 min read moveto() function in C The header file graphics.h contains moveto() function which changes the current position to (x, y) Syntax : void moveto(int x, int y); Examples : Input : x = 70, y = 40 Output : Input : x = 50, y = 80 Output : Below is the implementation of moveto() function: C // C Implementation for moveto() #incl 2 min read fma() function in C++ The fma() function takes three arguments a, b and c, and returns a*b+c without losing precision. The fma() function is defined in the cmath header file. If any argument passed to fma() is long double, the return type is long double. If not, the return type is double. Syntax: double fma(double a, dou 2 min read Like