How can I convert number of seconds since 1970 to DateTime in c++?



Hi,

I am trying to convert 1296575549:573352(of type std::string) into date time.
The left part of the colon is in seconds and the right part in micro seconds.

How can i do that?
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <time.h>

int main()
{
	const char time_as_str[] = "1296575549:573352";
	time_t t = atoi(time_as_str); // convert to time_t, ignores msec
	std::cout << asctime(localtime(&t));
	return 0;
}
Thanks kb
Topic archived. No new replies allowed.