Jump to content

timezone offset


kalster

Recommended Posts

instead of js alert displaying the timezone offset, i would like the content of get_time_zone_offset() to be used as a php variable.

<script type="text/javascript">
    function get_time_zone_offset( ) {
        var current_date = new Date();
        return -current_date.getTimezoneOffset() / 60;
    }

    alert("The local time zone is: GMT " + get_time_zone_offset());
</script>
Link to comment
https://forums.phpfreaks.com/topic/288851-timezone-offset/
Share on other sites

you can use PHP time zone instead of javascript  time zone 

 

Unless I'm missing something, that's just going to get the time zone for the server which may not match the time zone for the visitor.

 

 

instead of js alert displaying the timezone offset, i would like the content of get_time_zone_offset() to be used as a php variable.

 

You could look into using AJAX to communicate with PHP. Or could also look into passing the information through an HTML form.

Link to comment
https://forums.phpfreaks.com/topic/288851-timezone-offset/#findComment-1481274
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.