asctime() function in C++
The asctime() function is defined in the ctime header file. The asctime() function converts the given calendar time of structure tm to a character representation i.e human readable form.
Syntax:
char* asctime(const struct tm * time_ptr);
Parameter: This function accepts single parameter time_ptr i.e pointer to the tm object to be converted.
Return Value: This function returns the calender time in the form “Www Mmm dd hh:mm:ss yyyy”
Below program illustrate the asctime() function in C++:
Example:-
// c++ program to demonstrate // example of asctime() function. #include <bits/stdc++.h> using namespace std; int main() { time_t time_ptr; time(&time;_ptr); cout << "Current date and time = " << asctime(localtime(&time;_ptr)); return 0; } |
Current date and time = Mon Oct 1 10:21:26 2018
Recommended Posts:
- Function Overloading vs Function Overriding in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- div() function in C++
- fma() function in C++
- exp() function C++
- log() function in C++
- ilogb() function in C++ STL
- negate function in C++ STL
- map emplace_hint() function in C++ STL
- logb() function in C++ STL
- map count() function in C++ STL
- set upper_bound() function in C++ STL
- set lower_bound() function in C++ STL
- map erase() function in C++ STL
- map find() function in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.



