I would like to know how to display the time.
I know how to display the system clock
all I want is the time (eg hours/mins/secs)
Printable View
I would like to know how to display the time.
I know how to display the system clock
all I want is the time (eg hours/mins/secs)
Code:#include <iostream>
#include <ctime>
using namespace std;
int main()
{
time_t t;
struct tm* ti;
time(&t);
ti = localtime(&t);
cout << ti->tm_hour << ":" << ti->tm_min << ":" << ti->tm_sec<<endl;
return 0;
}
#include <iostream.h>
#include <time.h>
#include <iostream.h>
void main()
{
time_t hold_time;
hold_time=time(NULL);
cout<<ctime(&hold_time);
}