Skip to content

strtotime returns false when string includes narrow non breaking space character #11600

Closed
@myleshyson

Description

@myleshyson

Description

This is kind of related to #9799

With the ICU 72.1 update, it replaces a ascii space character with a narrow non-breaking space unicode character for intl space So something like

(new IntlDateFormatter('en_US', -1, 3))->getPattern();

will return h:mm\u202fa instead of h:mm a.

When creating date strings based off that pattern with the NNBS character, and then passing into strtotime, strtotime returns false.

With the ICU update, I think functions like strtotime should support parsing the NNBS character.

The following code:

<?php
$pattern = (new IntlDateFormatter('en_US', -1, 3))->getPattern();
$timeString = date($pattern, date('now'));
$timestamp = strtotime($timeString);

Resulted in this output:

false

But I expected this output instead:

a unix timestamp

PHP Version

8.2.8

Operating System

Redhat Enterprise 8.8

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions