Category Archives: Internet

Two ways too show the current year in a webpage

A simple example in PHP:

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

Note: PHP has to be integrated with a webserver.

A slightly less simple example in JavaScript:

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

Should work with any JS supporting browser

Posted in Webpages Tagged , ,