localtime() function in C++ Last Updated : 01 Oct, 2018 Comments Improve Suggest changes Like Article Like Report 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. Syntax: 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++: Example:- cpp // c++ program to demonstrate // example of localtime() function. #include <bits/stdc++.h> using namespace std; int main() { time_t time_ptr; time_ptr = time(NULL); // Get the localtime tm* tm_local = localtime(&time_ptr); cout << "Current local time is = " << tm_local->tm_hour << ":" << tm_local->tm_min << ":" << tm_local->tm_sec; return 0; } Output: Current local time is = 10:8:10 Comment More infoAdvertise with us Next Article localtime() function in C++ B bansal_rtk_ Follow Improve Article Tags : Misc C++ CPP-Library CPP-Functions Practice Tags : CPPMisc Similar Reads log() Function in C++ The std::log() in C++ is a built-in function that is used to calculate the natural logarithm (base e) of a given number. The number can be of any data type i.e. int, double, float, long long. It is defined inside the <cmath> header file.In this article we will learn about how to use std::log() 1 min read Function Pointer in C++ Prerequisites: Pointers in C++Function in C++ Pointers are symbolic representations of addresses. They enable programs to simulate call-by-reference as well as to create and manipulate dynamic data structures. Iterating over elements in arrays or other data structures is one of the main use of point 4 min read Function Pointer in C In C, a function pointer is a type of pointer that stores the address of a function, allowing functions to be passed as arguments and invoked dynamically. It is useful in techniques such as callback functions, event-driven programs, and polymorphism (a concept where a function or operator behaves di 6 min read mktime() function in C++ STL The mktime() is an inbuilt C++ function which converts the local calendar time to the time since epoch and returns the value as an object of type time_t. Syntax : time_t mktime( struct tm *time_ptr ) Parameters: The function accepts a mandatory parameter pointer time_ptr that points to a tm object s 2 min read Inline Functions in C++ In C++, inline functions provide a way to optimize the performance of the program by reducing the overhead related to a function call. When a function is specified as inline the whole code of the inline function is inserted or substituted at the point of its call during the compilation instead of us 6 min read Like