Skip to content

Instantly share code, notes, and snippets.

@magkopian
Last active November 10, 2015 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magkopian/f0724fa7faa629d302db to your computer and use it in GitHub Desktop.
Save magkopian/f0724fa7faa629d302db to your computer and use it in GitHub Desktop.
A simple JavaScript clock that automaticly syncs time using AJAX - Server (Client: https://gist.github.com/magkopian/7a97ff98c3cafe14972e)
<?php
if ( isset($_GET['action']) && !empty($_GET['action']) && $_GET['action'] == 'get_time' ) {
header('Content-type: application/json');
echo json_encode (
array (
'year' => date('Y'),
'month' => date('m'),
'day' => date('d'),
'hour' => date('h'),
'minute' => date('i'),
'second' => date('s')
)
);
}
else {
header('HTTP/1.1 404 Not Found');
echo '<h1>404 Not Found</h1>';
echo '<p>The page that you have requested could not be found.</p>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment