After some messing around with strtotime() in PHP I noticed that it gives a valid timestamp back when you pass in spaces and or dots.
var_dump(strtotime(" "));
var_dump(strtotime("."));
var_dump(strtotime(". .. .. .. .... .. . .. ."));
produces:
int 1443009652
int 1443009652
int 1443009652
Why does PHP see this as valid?
The simplest answer is some of them are false
y
var_dump(DateTime(false)); // date shown is current time
My bet is that the parser (which is trying to clean up a wide variety of acceptable inputs) strips the periods out (that are not being used as a delimiter), leaving only an empty string. It's the only explanation that makes sense.
echo strtotime('1.1.2000'); // outputs 946681200
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.