time() function in C Last Updated : 10 Jan, 2025 Comments Improve Suggest changes 31 Likes Like Report 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: C // C program to demonstrate // example of time() function. #include <stdio.h> #include <time.h> int main () { time_t seconds; seconds = time(NULL); printf("Seconds since January 1, 1970 = %ld\n", seconds); return(0); } OutputSeconds since January 1, 1970 = 1538123990Example 2: C // C program to demonstrate // example of time() function. #include <stdio.h> #include <time.h> int main() { time_t seconds; // Stores time seconds time(&seconds); printf("Seconds since January 1, 1970 = %ld\n", seconds); return 0; } OutputSeconds since January 1, 1970 = 1538123990 Create Quiz C Program to print digital clock with current time Comment B bansal_rtk_ Follow 31 Improve B bansal_rtk_ Follow 31 Improve Article Tags : Misc C Programs C Language C-Functions C-Library +1 More Explore C BasicsC Language Introduction6 min readIdentifiers in C3 min readKeywords in C2 min readVariables in C4 min readData Types in C3 min readOperators in C8 min readDecision Making in C (if , if..else, Nested if, if-else-if )7 min readLoops in C6 min readFunctions in C5 min readArrays & StringsArrays in C4 min readStrings in C5 min readPointers and StructuresPointers in C7 min readFunction Pointer in C5 min readUnions in C3 min readEnumeration (or enum) in C5 min readStructure Member Alignment, Padding and Data Packing8 min readMemory ManagementMemory Layout of C Programs5 min readDynamic Memory Allocation in C7 min readWhat is Memory Leak? How can we avoid?2 min readFile & Error HandlingFile Handling in C11 min readRead/Write Structure From/to a File in C3 min readError Handling in C8 min readUsing goto for Exception Handling in C4 min readError Handling During File Operations in C5 min readAdvanced ConceptsVariadic Functions in C5 min readSignals in C language5 min readSocket Programming in C8 min read_Generics Keyword in C3 min readMultithreading in C9 min read Like