- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library function - time()
Description
The C library function time_t time(time_t *seconds) returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds. If seconds is not NULL, the return value is also stored in variable seconds.
Declaration
Following is the declaration for time() function.
time_t time(time_t *t)
Parameters
seconds − This is the pointer to an object of type time_t, where the seconds value will be stored.
Return Value
The current calendar time as a time_t object.
Example
The following example shows the usage of time() function.
#include <stdio.h> #include <time.h> int main () { time_t seconds; seconds = time(NULL); printf("Hours since January 1, 1970 = %ld\n", seconds/3600); return(0); }
Let us compile and run the above program that will produce the following result −
Hours since January 1, 1970 = 393923
time_h.htm
Advertisements