All things going right until converting a string to an integer. After converting, the value becomes 0. Why?
<script type="text/javascript">
var offset = new Date().getTimezoneOffset(); //get client timezone differance with UTC
offset *= -1; // change sign
offset *= 60; // convert into second
console.log(offset);
</script>
<?php
echo "<br/><br/>";
$a = "<script>document.write(offset)</script>"; //getting value in string
echo $a; // this works and print : 19800
echo "<br/>";
settype($a, "integer");
echo $a; // print 0
?>
$awith the string inside it, not theoffsetthat you want to, and why not just use the javascript way of setting the type?$ais still"<script>document.write(offset)</script>";, when it its rendered into the page (since you echoed the script tags), now the JS kicks in, in turn showing you the illusion that the value is19800, so no$ais not actually19800$avariable is indeed a string, when page is loaded javascript executed and outputs (bydocument.write) previousy calculatedoffset.