Why isn't the toInt() working?

I'm trying to extract the unix timestamp from the string so that i later can convert it into readable time. But the toInt() gives the strange value: 2147483647 instead of 1639128199000.

String Unix = "Date(1639128199000)";
int unixTime = (Unix.substring(5, 18)).toInt();

...is an awfully large int

Do you know how I can do it in a better way?

Turn it into unsigned long long (aka uint64_t)?

How do i do that in code?

That's a really good question.
I've never had to do it.

Maybe try atoll () ?

(Though that's signed)

This worked

long long unixTime = atoll((unixRaw.substring(5, 18)).c_str());

Sorry, it appears the ato<xxx> functions are deprecated.
You should use "strtoull" instead.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.