Skip to content
Advertisement

Have I gone crazy, or has PHP’s strototime() broke? [closed]

Manual quote:

This page describes the different date formats that the strtotime()

“2008-6-30”

Source: https://www.php.net/manual/en/datetime.formats.date.php

Test code:

var_dump(strtotime('‎2008-6-30'));
var_dump(strtotime('‎2008-06-30'));

Expected output:

(two Unix timestamps)

Actual output:

bool(false)
bool(false)

I literally use the date used as an example in the manual, and even that doesn’t work.

I’m 99.9999999999999% sure that it used to work, not long ago.

PHP 7.4.11 @ Windows 10 Pro 2004.

What is wrong?

Advertisement

Answer

There’s a hidden character in your code, if I copy your code into https://sandbox.onlinephpfunctions.com/, there’s a red marked char in your string.

If I remove this, it works and prints out a timestamp.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement