The localtime() function is defined in the time.h header file. The localtime( ) function return the local time of the user i.e time present at the task bar in computer.
tm* localtime(const time_t* t_ptr);
Parameter: This function accepts a parameter t_ptr which represents the pointer to time_t object.
Return Value: This function returns a pointer to a struct tm object.
Below program illustrate the localtime() function in C:
Local time and date: Mon Sep 23 08:25:53 2019
Note: To understand this function clearly, change the time and date of your computer system and run the code again.
- btowc() function in C/C++ with Examples
- wcsspn() function in C/C++ with Examples
- getdate() and setdate() function in C with Examples
- C fopen() function with Examples
- getch() function in C with Examples
- Beep() function in C with Examples
- How to call function within function in C or C++
- Difference Between malloc() and calloc() with Examples
- Understanding "volatile" qualifier in C | Set 2 (Examples)
- Pointers in C/C++ with Examples
- Understanding Lvalues, PRvalues and Xvalues in C/C++ with Examples
- Logical Not ! operator in C with Examples
- iswprint() in C/C++ with Examples
- iswgraph() in C/C++ with Examples
- mbrtoc16() in C/C++ with Examples
- mbrtoc32() in C/C++ with Examples
- wmemset() in C/C++ with Examples
- Types of Literals in C/C++ with Examples
- cauchy_distribution a() in C++ with Examples
- chdir() in C language 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 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.