Bug #75259 [Nab]: getTimestamp and ->format('U') both return 32-bit int

From: Date: Tue, 26 Sep 2017 14:29:31 +0000
Subject: Bug #75259 [Nab]: getTimestamp and ->format('U') both return 32-bit int
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211363@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75259&edit=1 ID: 75259 User updated by: lewiscowles at me dot com Reported by: lewiscowles at me dot com Summary: getTimestamp and ->format('U') both return 32-bit int Status: Not a bug Type: Bug Package: Date/time related Operating System: Ubuntu Xenial (64-bit) PHP Version: 7.0.23 Block user comment: N Private report: N New Comment: Btw requinix@php.net. Totally solved for me +10000 you're awesome. Previous Comments: ------------------------------------------------------------------------ [2017-09-26 14:08:04] lewiscowles at me dot com <?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. ------------------------------------------------------------------------ [2017-09-26 14:04:12] lewiscowles at me dot com edit* both zero's at beginning ------------------------------------------------------------------------ [2017-09-26 13:56:38] lewiscowles at me dot com I expected to see > 32-bits, it's the first line of the description of the bug-report. But looks like I suck because it does return > 32-bits if I shift right by one on PHP_INT_MAX The expected result was what I expected, although if it's a signed int, maybe there would be two zero's (one at beginning and one at end) ------------------------------------------------------------------------ [2017-09-26 13:45:35] danack@php.net What date or time, do you think: new DateTime(PHP_INT_MAX << 1); is meant to result in? ------------------------------------------------------------------------ [2017-09-26 13:44:22] requinix@php.net It works fine. https://3v4l.org/DigKO Do not use the regular date string parsing functions (eg, new DateTime and strtotime) with a Unix timestamp because they treat the input as a formatted time string. https://3v4l.org/K5cNb ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=75259 -- Edit this bug report at https://bugs.php.net/bug.php?id=75259&edit=1

« previous php.bugs (#211363) next »