Skip to content

Instantly share code, notes, and snippets.

@MattRyanCo
Created March 14, 2015 22:03
Show Gist options
  • Save MattRyanCo/572d6a947034143426a3 to your computer and use it in GitHub Desktop.
Save MattRyanCo/572d6a947034143426a3 to your computer and use it in GitHub Desktop.
First dynamic website eg with edity
function currentTime() {
var currentTime = new Date();
var rhours, hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
if (minutes < 10) {
minutes = "0" + minutes;
}
if (hours > 12) {
rhours = hours - 12;
}
var format = rhours + ":" + minutes;
if (hours > 11) {
format = format + " PM";
} else {
format = format + " AM";
}
return format;
}
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script language="javascript" type="text/javascript" src="code.js"></script>
<script>
var time = currentTime()
</script>
</head>
<body>
<h1>Hello World!</h1>
<h2>It is <script>document.write(time)</script></h2>
</body>
</html>
h1 {
color: red;
}
h2 {
color: black;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment