VOOZH about

URL: https://www.geeksforgeeks.org/c/time-function-in-c/

⇱ time() function in C - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

time() function in C

Last Updated : 10 Jan, 2025

The time() function is defined in time.h (ctime in C++) header file. This function returns the time since 00:00:00 UTC, January 1, 1970 (Unix timestamp) in seconds. If second is not a null pointer, the returned value is also stored in the object pointed to by second.

Syntax:

time_t time( time_t *second )

Parameter: This function accepts single parameter second. This parameter is used to set the time_t object which store the time.
Return Value: This function returns current calendar time as a object of type time_t.

Time Complexity: O(1)

Auxiliary Space: O(1)

Program 1:


Output
Seconds since January 1, 1970 = 1538123990

Example 2:


Output
Seconds since January 1, 1970 = 1538123990
Comment