by Dinesh Thakur Category: Function and Pointer

The function time () returns the current calendar time, i.e., the number of seconds elapsed since 00:00:00 hour January 1, 1970 GMT (or gmt are used alternatively) up to the execution of the function. The function prototype is written as follows:

time_t time (time_t *Timeptr);

If Timeptr is not NULL, the return value gets stored in the memory pointed to by Timeptr. If unsuccessful, it returns a negative value.

Illustrates the application of function time () .

#include <stdio.h>
#include <time.h>
void main()
  time_t Time;
  Time = time(&Time);
  printf("Time = %u\n", Time);
Function time () in C

The number given in the output represents the number of seconds since 00:00:00 hours 01 January1970 GMT up to the execution of this program. In the following sections, we shall discuss the different conversion functions that convert the output of time () function into string representing day, date, hours, min, sec, year, etc.

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles