Getting actual time

is it possible to get actual time of the day via c++ program
I know how to get system which is just number of seconds
You can use std::localtime to get this kind of information.
1
2
3
4
5
6
7
8
9
#include <ctime>
#include <iostream>

int main()
{
	std::time_t time = std::time(0);
	std::tm* tm = std::localtime(&time);
	std::cout << "Time of the day: " << tm->tm_hour << ":" << tm->tm_min << std::endl;
}

Just wanted to share and ask what is this program displaying

1
2
3
4
5
6
7
8
9
10
#include<iostream>
#include<ctime>
#include<stdlib.h>
using namespace std;
int main()
{
    int timea = time(NULL);
    cout << timea;
    return 0;
}
By the way
Thanks :)
I think it shows no of seconds elapsed form 1970 time of unix i think
Topic archived. No new replies allowed.