breaststroke
Programmer
Hello, how are you!
I am working on php and trying to add some javascript code because I would like to get user's local timezone (GMT/UTC) and keep it in my database.
To do that I create a variable called GMT and try to pass it into another page through a form.
I have read something about it and I have come up with the following way to do it. But it is not working and I can not figure out why.
Well, it worked at the beginning on Google Chrome, but not on Firefox. Trying to fix it..now it doesn't work on any browser (I would swear now it's as it was at first..).
I would appreciate any help.
When trying to get its value on the page the form is addressed to I get nothing.
I try it doing this:
p.s. sorry to insist, but it worked fine at the beginning. I just tried to change its position or something. Now even though I am pretty sure it is placed on the same point, I can't make it work.
I would be more than happy to get any idea about it.
Regards!!
I am working on php and trying to add some javascript code because I would like to get user's local timezone (GMT/UTC) and keep it in my database.
To do that I create a variable called GMT and try to pass it into another page through a form.
I have read something about it and I have come up with the following way to do it. But it is not working and I can not figure out why.
Well, it worked at the beginning on Google Chrome, but not on Firefox. Trying to fix it..now it doesn't work on any browser (I would swear now it's as it was at first..).
I would appreciate any help.
Code:
<?php
...
print<<<HERE
..
<input type="hidden" id="utc" name="utc">
..
HERE;
?>
<script>
var d = new Date();
var GMT = -d.getTimezoneOffset()/60;
document.getElementById("utc").value=GMT;
</script>
<?php
..
..
HERE;
When trying to get its value on the page the form is addressed to I get nothing.
I try it doing this:
Code:
...
$utc=$_POST['utc'];
echo $utc;
..
..
p.s. sorry to insist, but it worked fine at the beginning. I just tried to change its position or something. Now even though I am pretty sure it is placed on the same point, I can't make it work.
I would be more than happy to get any idea about it.
Regards!!