Skip to content

Commit

Permalink
Fix an error with newer PHP versions erroring on date() calls
Browse files Browse the repository at this point in the history
This solves: Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int, string given in ...

You can recreate this error with the following code:

```
$x = [ 'query_time' => '123456789 ms', 'query_time2' => 123456789 ];
k($x);
```
  • Loading branch information
scottchiefbaker committed Jun 1, 2022
1 parent b0b237d commit d2060a4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion class.krumo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ private static function plural($number, $word)
private static function is_datetime($name, $value)
{
// If the name contains date or time, and the value looks like a unixtime
if (preg_match("/date|time/i", $name) && ($value > 10000000 && $value < 4000000000)) {
if (preg_match("/date|time/i", $name) && (is_numeric($value) && $value > 10000000 && $value < 4000000000)) {
$ret = date("r", $value);

return $ret;
Expand Down

0 comments on commit d2060a4

Please sign in to comment.