0

i want a design and develop a web page which will show the current time on the basis of the

request. eg if the request of the page is come from dubai then the server automaticaly finds

the current time of dubai and writes that time on the page. similarly if the request comes

from india then the server aoutomatically finds the curent time of india and write that time

on the page before sending that page to the client????

5
Contributors
4
Replies
7
Views
5 Years
Discussion Span
Last Post by diafol
-1

1; Set index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>

<body>

<?php
session_start();
echo $timezone = $_SESSION['timezone'];

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

                    location.reload();
                }
            });
        }
    });
</script>

2; Set time.php

<?php
    session_start();
    $_SESSION['timezone'] = $_GET['timezone'];
?>
Votes + Comments
Don't copy somebody else's code and supply it as your own. A link is sufficient
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.