convert a string 1441970667234 to date, time_t; atoi

Beginner in c++, il would like to convert a string "1441970667234" to date.

1
2
3
  const char time_as_str[] = "1441970667234";
  time_t t = atoi(time_as_str);
  asctime(localtime(&t))


result
Tue Dec 5 17:16:18 1933 ? it should be september 2015

i see number of exemple for current date but not for my case

Thanks
1) You have overflow here: 1441970667234 will not fit into int.
2) Actual value and precision of time_t is implementation-defined. If you have POSIX time, then you have too many digits, you need to use 1441970667 as your time value.
Topic archived. No new replies allowed.