The localtime() function is defined in the ctime header file. The localtime() function converts the given time since epoch to calendar time which is expressed as local time.
tm* localtime(const time_t* time_ptr);
Parameter: This function accepts a parameter time_ptr which represents the pointer to time_t object.
Return Value: This function returns a pointer to a tm object on success, Otherwise it returns NullPointerException.
Below program illustrate the localtime() function in C++:
Current local time is = 10:8:10
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- How to call function within function in C or C++
- Difference between user defined function and library function in C/C++
- Function overloading and return type
- Function Pointer in C
- Function overloading and const keyword
- Comparator function of qsort() in C
- Function Overloading and float in C++
- Extra brackets with function names in C/C++
- Function Interposition in C with an example of user defined malloc()
- A C/C++ Function Call Puzzle
- std::tuple, std::pair | Returning multiple values from a function using Tuple and Pair in C++
- Bind function and placeholders in C++
- strftime() function in C/C++
- Function Overloading in C++
- std::gcd | C++ inbuilt function for finding GCD
- Power Function in C/C++
- Understanding ShellExecute function and it's application to open a list of URLs present in a file using C++ code
- wcscpy() function in C++ with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.