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(){
|
||||
var current_time = new Date();
|
||||
var formated_time = current_time.getHours() + ":"
|
||||
var current_time = new Date(),
|
||||
formated_time = current_time.getHours() + ":"
|
||||
+ current_time.getMinutes() + ":"
|
||||
+ current_time.getSeconds();
|
||||
document.getElementById('time_title').innerHTML = "Time is: " + formated_time;
|
||||
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>
|
||||
<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 name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<meta name="author" content="efrick"/>
|
||||
@ -13,19 +17,12 @@
|
||||
</h1>
|
||||
<div class="body">
|
||||
<?php
|
||||
$temp = "The date is ";
|
||||
echo $temp . longdate(time());
|
||||
echo "<br>";
|
||||
echo "<p id='time_body'>Clock</p>";
|
||||
$my_tz = date_timezone_get();
|
||||
echo date("l M d Y H:i:s") . "$my_tz";
|
||||
function longdate($timestamp)
|
||||
{
|
||||
return date("l F jS Y", $timestamp);
|
||||
}
|
||||
|
||||
echo "The full date and time:".
|
||||
"<br>".
|
||||
"<p id='time_body'>".
|
||||
date("D M d Y H:i:s") .
|
||||
" GMT" . date("O") . " (" . date("T") . ")"."</p>";
|
||||
?>
|
||||
<p id='time_test'>Test</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user