I'm a little unclear here as to what's going on/being asked. Is that your page you've linked to?
In any case, an XML file shouldn't be required. Javascript/AJAX can pass the user's time and/or timezone offset directly to a PHP page. In fact, AJAX might not be required. Any PHP page which loads into the browser can use javascript to get the user's time.
It might actually be better to use PHP (or any available server side code) to get the server time and use that to find the target time in the client's timezone, then use javascript to calculate the user's time and do the other work to setup the alarm clock.
For an example of a script that does something like that, see:
http://www.dynamicdrive.com/dynamici...lcountdown.htm
But if you still want to write an XML file with the user's local time in it, AJAX alone cannot do that. But it can send the data to the server, which can use PHP to write the XML file. But I think the user's minutes difference from UTC might also be helpful, so:
timedemo.htm:
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
(function($){
var date = new Date();
$.ajax({
url: 'makexmlfile.php',
data: {'zoneoffset' : date.getTimezoneOffset(), 'usertime': Math.round(date.getTime() / 1000)},
cache: false/* ,
success: function(data){ //uncomment this red section for diagnostics if desired
console.log(data);
} */
});
})(jQuery);
</script>
</head>
<body>
</body>
</html>
makexmlfile.php:
PHP Code:
<?php
if(!isset($_REQUEST['zoneoffset']) or !isset($_REQUEST['usertime'])){die();}
$useroffset = $_REQUEST['zoneoffset'];
$usertime = $_REQUEST['usertime'];
$xml = "<data>
<offset>$useroffset</offset>
<usertime>" . date('Y-m-d-H-i-s', $usertime) . "</usertime>
</data>";
file_put_contents('user.xml', $xml); //requires PHP 5 or greater, there is a fall back if needed for PHP 4
?>
A typical resulting user.xml file:
Code:
<data>
<offset>240</offset>
<usertime>2013-05-08-02-06-52</usertime>
</data>
But this is inferior to any real time processing (like the first idea in this post, and others that could be worked out) due to the likelihood that two users might collide over the use of the XML file, unless a unique XML file is generated for each user.
Bookmarks