|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-09-26 13:34 UTC] lewiscowles at me dot com
Description: ------------ I expected to see > 32-bits (I'd really love to know how to get > 32bits of time-data if this is the expected behaviour) Test script: --------------- --- From manual page: http://www.php.net/datetime.gettimestamp --- <?php // PHP Get Integer Size (wouldn't expect 32-bit OS to deal with 64-bit Int's) var_dump(PHP_INT_SIZE); // setup $dt = new DateTime(PHP_INT_MAX << 1); // should return 64-bit max shifted left once var_dump(sprintf("%064b", $dt->format('U'))); // should return 64-bit max shifted left once var_dump(sprintf("%064b", $dt->getTimestamp())); Expected result: ---------------- // int(8) // string(64) "0111111111111111111111111111111111111111111111111111111111111111" // string(64) "0111111111111111111111111111111111111111111111111111111111111111" // Note I may have the zero in the wrong place, can't remember if the most or least significant bit is supposed to be shifted, but you get the picture). Actual result: -------------- // int(8) // string(64) "0000000000000000000000000000000001011001110010100111110111011010" // string(64) "0000000000000000000000000000000001011001110010100111110111011010" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 21:00:01 2025 UTC |
<?php echo sprintf("%064b\n", PHP_INT_MAX); echo sprintf("%064b\n", PHP_INT_MAX>>1); 0111111111111111111111111111111111111111111111111111111111111111 0011111111111111111111111111111111111111111111111111111111111111 What I mean is I expected to see these numbers or similar numbers from the DateTime function as they reflect the time-stamp passed in. There's a specification I'd like to implement that wants 48-bits of time. I apologize for being thick and shifting the wrong way in the original. I'm still not sure that the numbers output looked anything like what I expected.