$date = "1346706576967"; // miliseconds $newDate = (int) $date; echo $newDate;
I get "2147483647" as $ newDate.
I just want to convert a variable from String 1346706576967 to int 1346706576967 - how is this possible?
2147483647 is the largest value, to which, unfortunately, an integer refers. You can use float instead, since float can store integer values ββexactly up to 1,000,000,000,000
Because this is the maximum size an integer can have in PHP. You will need a special PHP library designed to work with large integers such as BCMath or GMP, or just convert it to a float.
possible conversions
$input => 1346706576967 (integer)$input => 2147483647 intval($input) => 2147483647 $input*1 => 1346706576967 settype($input, "integer") => 1346706576967
http://phpconvert.com/online/
You can use implicit conversion to convert it correctly:
$date = "1346706576967"; // miliseconds $newDate = 0+$date; // float(1346706576967) $newDate = (int) $date; // int(2147483647)
Source: https://habr.com/ru/post/1433002/More articles:Windows authentication restricts a specific domain - authenticationApplication downloader: Apple web service failed - iosIs there an equivalence equivalence in Ruby? - ruby ββ| fooobar.comUsing urllib3 or queries and Celery - pythonSQL counts on a field that is code - sqlReturn clause that appears click - javascriptHow to make sql member provider and entity structure work with my database? - .netRubymine debugging - only debug project files? - debuggingKnitr chunk imports a subset of records from * .csv as the same code in R - rMethod call Async TaskCompletionSource twice - c #All Articles