PHP is being compiled first on the server, you are assuming that
$var = "<script>document.write(date)</script>";
is resolving to something like $var = "05/20/2016 12:00";
but it isn't because the javascript compiling doesn't kick in until the output has reached the client.
You're passing the literal string "<script>document.write(date)</script>"
to PHP's strtotime()
function, hence returning a zero.
If you echo $var
prior to echo gettype($var)
you'll see exactly what is being passed to strtotime.
var_dump()
is even better for debugging the current value of a variable.
$var = "<script>document.write(date)</script>";
var_dump($var)
echo gettype ($var);
$ini = strtotime($var)*1000;