localtime() function in C++
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++:
* tm_local =
"Current local time is = "
<< tm_local->tm_hour <<
<< tm_local->tm_min <<
Current local time is = 10:8:10
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!