<!doctype html>
<!-- Name:Thomas Smith
Email:tsmith27@my.athens.edu
Student No.00048668 -->
<!-- ============================================================== -->
<html>
<head>
<meta charset="utf-8">
<title>Time Remaining</title>
<body>
<h1 style="text-align:left">How Much Time Until?</h1>
<br>
<p>Enter the date: <input type="text" id="endBox" size=16 value=''></p>
<br>
<br>
<hr>
<input type="button" value="Find Out" style="width:130px;" onclick="javascript:TimeUntil();"/>
<div id="outputDiv"></div>
<script type="text/javascript" src="time.js"></script>
<script type="text/javascript">
function TimeUntil()
{document.getElementById('endBox').value);
var seconds = SecondsUntil('endBox');
var time = SecondsToString(answer);
return time;
}
function SecondsToString(seconds)
{
var days = Math.floor(seconds / (24*60*60));
seconds = seconds - days*(24*60*60);
var hours = Math.floor(seconds / (60*60));
seconds = seconds - hours*(60*60);
var minutes = Math.floor(seconds / 60);
seconds = seconds - minutes*60;
var answer = days + ' days, ' + hours + ' hours, ' + minutes + ' minutes, ' +
seconds + ' seconds';
}
function SecondsUntil(endBox)
{
var goalDate = new Date(endBox);
var current = new Date();
var diff = Math.floor((goalDate - current)/1000);
document.getElementById('outputDiv')innerHTML = "Time left is " + diff;
}
</script>
</body>
</html>
Thomas_31 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.