« first day (3789 days earlier)      last day (1163 days later) » 

9:12 AM
Yeah. With PHP sadly you quickly find (old) answers to problems that use code which wouldn't be considered best practice (anymore)
 
 
12 hours later…
8:57 PM
One possible reason that I just noticed is that filter_var() can't process multibyte characters, even in 2021. Try this and the results will be funny!
echo filter_var( 'Hello WorldÆØÅ!', FILTER_SANITIZE_STRING, [ 'flags' => FILTER_FLAG_ENCODE_HIGH ] );
 
9:09 PM
that's expected though, The FILTER_SANITIZE_STRING filter removes tags and remove or encode special characters from a string.
it's intended for strings that are to be put in HTML as plain text
php > echo filter_var( 'Hello WorldÆØÅ!', FILTER_SANITIZE_STRING, [ 'flags' => FILTER_FLAG_ENCODE_HIGH ] );
Hello WorldÆØÅ!
php >
it encoded the non-latin characters
I don't see any evidence it doesn't handle multibyte values
 
It's not the correct output. There are 3 unicode characters in the original text, while PHP output 6 encoded chars
The proper output is this:
Hello WorldÆØÅ!
What you got from the output will look like this: Hello WorldÆØÅ!
The only way I've found to properly filter it is this:
echo filter_var( mb_convert_encoding( 'Hello WorldÆØÅ!', 'utf-16' ), FILTER_SANITIZE_STRING, [ 'flags' => FILTER_FLAG_ENCODE_HIGH ] );
 

« first day (3789 days earlier)      last day (1163 days later) »