Skip to content

strtotime unexpected result with white space #19803

@Paxtez

Description

@Paxtez

Description

Passing white space to strtotime() gives the current time. I assume it's parsing it as an empty date (which means now) + and empty modifier (which means nothing), so now + 0 = now.

But it seems like it should (?) return false if the date and modifier are both empty.

The following code:

<?php
$date = ' ';
$utc = strtotime($date);
var_dump($date);
var_dump($utc);
?>

Resulted in this output:

string(1) " "
int(1757608141)

But I expected this output instead:

string(1) " "
bool(false)

PHP Version

8.2.20

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions