Codes for HTML current date

Asked By 0 points N/A Posted on -


I was wondering how to show the current date on an HTML document using notepad.


Best Answer by Taylor Laura
Answered By 0 points N/A #162035

Codes for HTML current date


Hi there. You can get codes to do that in the following links:

You can also use java script to display the current date and time.

Many people disagree that html can do that because it doesn't interact with the user and the machine.

To use JavaScript to do that, here's a code


Best Answer
Best Answer
Answered By 0 points N/A #162036

Codes for HTML current date



It would be impossible to use just an HTML language alone to show the current time or date.  

You need a language that could interact with your computer and with the user, so you can eventually capture the current time.  

This is where Java scripting comes.  

The good news though is that you can integrate both programs to display the time and date on your browser.

First start creating the HTML skeleton:








Then add meta elements after the <head> tag.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Content-Script-Type" content="text/javascript">

<meta name="Content-Style-Type" content="text/css">

The meta elements written above will tell your browser that it's going to use JavaScript, html and CSS program in your current program.  

In your <body> insert the following program:

<script type="text/javascript">

document.write ('<p>Current time is: <span id="date-time">', new Date().toLocaleString(), '</span>.</p>')

if (document.getElementById) onload = function () {

setInterval ("document.getElementById ('date-time') = new Date().toLocaleString()", 50)}


This program is a standard Javascript program that will display the current time and date in your browser.  Combining it all together this is how it will look like:

I coded this program in notepad, and it worked so far.

Good luck.

Login/Register to Answer

Related Questions