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
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Difference between user defined function and library function in C/C++
- 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 Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- exp() function C++
- log() function in C++
- div() function in C++
- fma() function in C++
- clock() function in C/C++
- wctrans() function in C/C++
- fegetenv() function in C/C++
- fegetexceptflag() function in C/C++
- nearbyint() function in C++
- wmemcpy() function in C/C++
- scalbn() function in C++
- isfinite() function in C++
- wmemmove() function in c++
- difftime() function in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.