Two ways too show the current year in a webpage

A simple example in PHP:


<html>
<body>
<span><? echo date('Y') ?></span>
</body>
</html>

Note: PHP has to be integrated with a webserver.

A slightly less simple example in JavaScript:


<html>
<script>
function currentYear() {
  y = new Date();
  document.getElementById("year").innerHTML = y.getFullYear();
}
</script>
<body onload="currentYear()">
<span id="year"></span>
</body>
</html>

Should work with any JS supporting browser

Category(s): Webpages
Tags: , ,

Comments are closed.