cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
convert a string 1441970667234 to date,
convert a string 1441970667234 to date, time_t; atoi
Sep 16, 2015 at 10:10am UTC
java777
(1)
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
Sep 16, 2015 at 11:17am UTC
MiiNiPaa
(8886)
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.