Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to get the user's time zone using PHP and Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.20k
    Comment on it

    Hello Reader! If you developing the website for a global purpose then getting the time zone of your user is a important factor.
    In the example below we'll see how to get the user's time zone by using JavaScript and PHP with a custom webpage.

    First get the jquery file (The latest one) and call it on header <script type="text/javascript" src=""></script>

    Now write this is custom Jquery just below it:-

    <script type="text/javascript">
        $(document).ready(function() {
            if("<?php echo $timezone; ?>".length==0){
                var visitortime = new Date();
                var visitortimezone = "GMT " + -visitortime.getTimezoneOffset()/60;
                    type: "GET",
                    url: "",
                    data: 'time='+ visitortimezone,
                    success: function(){

    Where is your website and date.php is our next page

    Now the last step is to create date.php in the location as in url above

        $_SESSION['time'] = $_GET['time'];

    Now it will return the user's timezone.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: