Public bug reported:
I found a bug on all php version of ubuntu. Litterally strtotime looks
like float between two timezones
<?php
$day = 86400;
$from = '2021-01-01';
$to = '2021-12-31';
$tmFrom = strtotime($from);
$tmTo = strtotime($to);
$days = intval(($tmTo - $tmFrom) / $day) + 1;
for ($i = 0; $i < $days; $i++) {
$start = intval($tmFrom);
$daystoadd = intval($day * $i);
$thisday = $start + $daystoadd;
$thisdayWrong = strtotime(date('Y-m-d', $thisday));
// this IF should not works at all
if($thisdayWrong !== $thisday) {
$diff = $thisday - $thisdayWrong;
echo ' your php has a bug -> '
. $start . ' + '
. $daystoadd
. ' = ' . $thisday . ' but get ' . $thisdayWrong
. ' with strtotime '
. 'diff = ' . $diff
. PHP_EOL;
}
}
** Affects: php-defaults (Ubuntu)
Importance: Undecided
Status: New
** Description changed:
I found a bug on all php version of ubuntu. Litterally strtotime looks
like float between two timezones
<?php
$day = 86400;
$from = '2021-01-01';
$to = '2021-12-31';
$tmFrom = strtotime($from);
$tmTo = strtotime($to);
$days = intval(($tmTo - $tmFrom) / $day) + 1;
for ($i = 0; $i < $days; $i++) {
$start = intval($tmFrom);
$daystoadd = intval($day * $i);
$thisday = $start + $daystoadd;
- $thisdayWrong = strtotime(date('Y-m-d', intval($tmFrom) +
intval(($day * $i))));
- // this IF should not works at all
+ $thisdayWrong = strtotime(date('Y-m-d', $start + $daystoadd));
+ // on compiled php this IF not works at all
if($thisdayWrong !== $thisday) {
$diff = $thisday - $thisdayWrong;
echo ' your php has a bug -> '
. $start . ' + '
. $daystoadd
. ' = ' . $thisday . ' but get ' . $thisdayWrong . ' with
strtotime '
. 'diff = ' . $diff
. PHP_EOL;
}
}
** Description changed:
I found a bug on all php version of ubuntu. Litterally strtotime looks
like float between two timezones
<?php
$day = 86400;
$from = '2021-01-01';
$to = '2021-12-31';
$tmFrom = strtotime($from);
$tmTo = strtotime($to);
$days = intval(($tmTo - $tmFrom) / $day) + 1;
for ($i = 0; $i < $days; $i++) {
- $start = intval($tmFrom);
- $daystoadd = intval($day * $i);
- $thisday = $start + $daystoadd;
- $thisdayWrong = strtotime(date('Y-m-d', $start + $daystoadd));
- // on compiled php this IF not works at all
- if($thisdayWrong !== $thisday) {
- $diff = $thisday - $thisdayWrong;
- echo ' your php has a bug -> '
- . $start . ' + '
- . $daystoadd
- . ' = ' . $thisday . ' but get ' . $thisdayWrong . ' with
strtotime '
- . 'diff = ' . $diff
- . PHP_EOL;
- }
+ $start = intval($tmFrom);
+ $daystoadd = intval($day * $i);
+ $thisday = $start + $daystoadd;
+ $thisdayWrong = strtotime(date('Y-m-d', $start + $daystoadd));
+ // on compiled php this IF not works at all
+ if($thisdayWrong !== $thisday) {
+ $diff = $thisday - $thisdayWrong;
+ echo ' your php has a bug -> '
+ . $start . ' + '
+ . $daystoadd
+ . ' = ' . $thisday . ' but get '
+ . $thisdayWrong . ' with strtotime '
+ . 'diff = ' . $diff
+ . PHP_EOL;
+ }
}
** Description changed:
I found a bug on all php version of ubuntu. Litterally strtotime looks
like float between two timezones
<?php
$day = 86400;
$from = '2021-01-01';
$to = '2021-12-31';
$tmFrom = strtotime($from);
$tmTo = strtotime($to);
$days = intval(($tmTo - $tmFrom) / $day) + 1;
for ($i = 0; $i < $days; $i++) {
$start = intval($tmFrom);
$daystoadd = intval($day * $i);
$thisday = $start + $daystoadd;
- $thisdayWrong = strtotime(date('Y-m-d', $start + $daystoadd));
- // on compiled php this IF not works at all
+ $thisdayWrong = strtotime(date('Y-m-d', intval($tmFrom) +
intval(($day * $i))));
+ // this IF should not works at all
if($thisdayWrong !== $thisday) {
$diff = $thisday - $thisdayWrong;
echo ' your php has a bug -> '
. $start . ' + '
. $daystoadd
- . ' = ' . $thisday . ' but get '
- . $thisdayWrong . ' with strtotime '
+ . ' = ' . $thisday . ' but get ' . $thisdayWrong
+ . ' with strtotime '
. 'diff = ' . $diff
. PHP_EOL;
}
}
** Description changed:
I found a bug on all php version of ubuntu. Litterally strtotime looks
like float between two timezones
<?php
$day = 86400;
$from = '2021-01-01';
$to = '2021-12-31';
$tmFrom = strtotime($from);
$tmTo = strtotime($to);
$days = intval(($tmTo - $tmFrom) / $day) + 1;
for ($i = 0; $i < $days; $i++) {
$start = intval($tmFrom);
$daystoadd = intval($day * $i);
$thisday = $start + $daystoadd;
- $thisdayWrong = strtotime(date('Y-m-d', intval($tmFrom) +
intval(($day * $i))));
+ $thisdayWrong = strtotime(date('Y-m-d', $thisday));
// this IF should not works at all
if($thisdayWrong !== $thisday) {
$diff = $thisday - $thisdayWrong;
echo ' your php has a bug -> '
. $start . ' + '
. $daystoadd
- . ' = ' . $thisday . ' but get ' . $thisdayWrong
- . ' with strtotime '
+ . ' = ' . $thisday . ' but get ' . $thisdayWrong
+ . ' with strtotime '
. 'diff = ' . $diff
. PHP_EOL;
}
}
** Summary changed:
- PHP all vesions math error on large integers
+ PHP all vesions, litterally strtotime looks like float between two timezones
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1936230
Title:
PHP all vesions, litterally strtotime looks like float between two
timezones
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/php-defaults/+bug/1936230/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs