Skip to content

Instantly share code, notes, and snippets.

@Largo
Created April 17, 2014 08:25
Show Gist options
  • Save Largo/10964346 to your computer and use it in GitHub Desktop.
Save Largo/10964346 to your computer and use it in GitHub Desktop.
html, body{
height: 100%;
}
#clock {
font-size: 50px;
/* font-family: 'Helvetica, Arial';
color: #3e3e3e; */
}
.wrap {
/*background: #fff;
margin: 0 auto;
width: 300px;
text-align: center;
padding: 10px; */
}
.wrap {
text-align: center;
}
@media (min-device-width: 768px) {
.outer-wrap {
display: -webkit-flex;
display: flex;
width: 100%;
height: 100%;
}
.wrap {
-webkit-align-self: center;
align-self: center;
width: 400px;
margin: 0 auto;
}
}
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="http://getbootstrap.com/2.3.2/assets/css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/2.3.2/assets/js/bootstrap.js"></script>
<meta charset="utf-8">
<title></title>
</head>
<body onload="updateClock(); setInterval('updateClock()', 1000 )">
<div class="outer-wrap">
<div class="well wrap">
<h1 id="clock">&nbsp;</h1>
</div>
</div>
</body>
</html>
function updateClock ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
// Pad the minutes and seconds with leading zeros, if required
currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
// Compose the string for display
var currentTimeString = currentHours + 'h' + " : " + (currentMinutes / 60 * 100 ).toFixed(0) + '%' + " : " + (currentSeconds / 60 * 100).toFixed(0) + '%';
// Update the time display
document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment