Why does strtotime ('') and strtotime ('.') Return a timestamp?

After some messing with strtotime () in PHP, I noticed that it returns a valid timestamp when you pass spaces and periods.

var_dump(strtotime(" ")); var_dump(strtotime(".")); var_dump(strtotime(". .. .. .. .... .. . .. .")); 

gives:

 int 1443009652 int 1443009652 int 1443009652 

Why does PHP consider this to be valid?

+7
php strtotime
source share
1 answer

The simplest answer is some of them: false y

 var_dump(DateTime(false)); // date shown is current time 

My bet is that the parser (which is trying to clear a large number of acceptable inputs) separates the periods (which are not used as a separator), leaving only an empty string. This is the only explanation that makes sense.

 echo strtotime('1.1.2000'); // outputs 946681200 
+2
source share

All Articles