Cleaned up both the PHP/HTML and JavaScript code.
Removed the orignal PHP date formating. The code now runs so that PHP will inishilize a view on the page and JS will then update this. The formating of the Timezone doesn't seem to be consistant acrossed browsers. And JS doesn't format time with leading zeros for minutes or seconds which is odd. This may be fixed in a further revision.
This commit is contained in:
parent
453a3c561f
commit
a53376f57e
5
clock.js
5
clock.js
@ -5,11 +5,10 @@ function startInterval(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startTime(){
|
function startTime(){
|
||||||
var current_time = new Date();
|
var current_time = new Date(),
|
||||||
var formated_time = current_time.getHours() + ":"
|
formated_time = current_time.getHours() + ":"
|
||||||
+ current_time.getMinutes() + ":"
|
+ current_time.getMinutes() + ":"
|
||||||
+ current_time.getSeconds();
|
+ current_time.getSeconds();
|
||||||
document.getElementById('time_title').innerHTML = "Time is: " + formated_time;
|
document.getElementById('time_title').innerHTML = "Time is: " + formated_time;
|
||||||
document.getElementById('time_body').innerHTML = Date();
|
document.getElementById('time_body').innerHTML = Date();
|
||||||
document.getElementById('time_test').innerHTML = current_time.getDate();
|
|
||||||
}
|
}
|
||||||
|
23
clock.php
23
clock.php
@ -1,6 +1,10 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title id='time_title'>Clock</title>
|
<title id='time_title'>
|
||||||
|
<?php
|
||||||
|
echo "Time is: " . date("H:i:s");
|
||||||
|
?>
|
||||||
|
</title>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<meta name="author" content="efrick"/>
|
<meta name="author" content="efrick"/>
|
||||||
@ -13,19 +17,12 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<?php
|
<?php
|
||||||
$temp = "The date is ";
|
echo "The full date and time:".
|
||||||
echo $temp . longdate(time());
|
"<br>".
|
||||||
echo "<br>";
|
"<p id='time_body'>".
|
||||||
echo "<p id='time_body'>Clock</p>";
|
date("D M d Y H:i:s") .
|
||||||
$my_tz = date_timezone_get();
|
" GMT" . date("O") . " (" . date("T") . ")"."</p>";
|
||||||
echo date("l M d Y H:i:s") . "$my_tz";
|
|
||||||
function longdate($timestamp)
|
|
||||||
{
|
|
||||||
return date("l F jS Y", $timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<p id='time_test'>Test</p>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user