Home

bennet @de52c78911f353528985c459ac26e4f39cf3caea - refs - log -
-
https://git.jolheiser.com/bennet.git
Bean boy
bennet / site / index.html
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<html>
	<head>
		<link rel="stylesheet" href="odometer.css">
		<link rel="stylesheet" href="baby.css">

		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

		<script src="odometer.js"></script>
	</head>
	<body>
	<table>
		<tbody>
			<tr><td colspan="2"><span class="label">How old am I?</span></td></tr>
			<tr><td><div id="year" class="odometer">0</div></td><td><span class="label">Years</span></td></tr>
			<tr><td><div id="month" class="odometer">0</div></td><td><span class="label">Months</span></td></tr>
			<tr><td><div id="week" class="odometer">0</div></td><td><span class="label">Weeks</span></td></tr>
			<tr><td><div id="day" class="odometer">0</div></td><td><span class="label">Days</span></td></tr>
			<tr><td><div id="hour" class="odometer">0</div></td><td><span class="label">Hours</span></td></tr>
			<tr><td><div id="minute" class="odometer">0</td><td></div><span class="label">Minutes</span></td></tr>
			<tr><td><div id="second" class="odometer">0</div></td><td><span class="label">Seconds</span></td></tr>
		</tbody>
	</table>


	<script type="text/javascript">
		
		$(document).ready(function() {
			var birth = new Date("04/12/1992 00:00:00");
			var now = new Date();
			var diff = Math.round((now.getTime() - birth.getTime()) / 1000); // Time in seconds
			setInterval(function() {
				calcYear(diff);
				calcMonth(diff);
				calcWeek(diff);
				calcDay(diff);
				calcHour(diff);
				calcMinute(diff);
				calcSecond(diff);
				diff++; // Add a second each second
			}, 1000);

		});
		
		function calcYear(diff) {
			$("#year").html(Math.floor(diff / 31536000));
		}
		
		function calcMonth(diff) {
			$("#month").html(Math.floor(diff / 2628000));
		}
		
		function calcWeek(diff) {
			$("#week").html(Math.floor(diff / 657000));
		}
		
		function calcDay(diff) {
			$("#day").html(Math.floor(diff / 87600));
		}
		
		function calcHour(diff) {
			$("#hour").html(Math.floor(diff / 3650));
		}
		
		function calcMinute(diff) {
			$("#minute").html(Math.floor(diff / 60));
		}
		
		function calcSecond(diff) {
			$("#second").html(Math.floor(diff));
		}
	</script>
	
	</body>
</html>