Introduction
C++ is a powerful programming language for your competitive programming. To get flawless control in this language, you can refer to this amazing article on Coding Ninjas Studio. C++ STL consists of a lot of inbuilt functions with different functionalities. The localtime() function is one of those functions. The localtime() function is used to convert the given time into the local time. It is present in the <ctime> header file and we can use it by importing this header file.
Also see, Literals in C, Fibonacci Series in C++
Syntax
localtime(time_t* timer);
Parameter
It accepts a timer value which is a pointer to the time_t object.
Return Value
The localtime() function returns a pointer pointing to the structure of the time which is stored in the local timezone.
CODE
#include <bits/stdc++.h>
using namespace std;
int main(){
time_t hold;
hold = time(NULL);
tm* hold_local = localtime(&hold);
cout<<"Current local time of system is: "<< hold_local->tm_hour << ":"<<hold_local->tm_min << ":"<<hold_local->tm_sec;
return 0;
}