answersLogoWhite

0


Best Answer

You can't do it in HTML, but you can in javascript or PHP, which can be added to an HTML document. Just add the code to where you want it to display the time.

<?PHP print(Date("l F d, Y")); ?>

<script type="text/javascript">

<!--

document.write(Date());

-->

</script>

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

HTML can't get the time for you, so the best way to do it is to use Javascript inside your page, like this:

<script language="javascript">

<!--

today = new Date();

document.write("<BR>The time now is: ", today.getHours(),":",today.getMinutes());

document.write("<BR>The date is: ", today.getDate(),"/",today.getMonth()+1,"/",today.getYear());

//-->

</script>

Copy and paste that into your web page code. It will show you the date and time.

See related links for details about how to incorporate this function in an input box.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

There are many ways to display the current date and time with javascript. Here is an example of one way to do it:


You can play around with the document.write section to format as you prefer.


This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Here is the JavaScript code for adding date and time to your HTML. Reformat the document.write statement to meet your needs.

<b>

<script type="text/javascript">

<!--

var currentTime = new Date()

var month = currentTime.getMonth() + 1

var day = currentTime.getDate()

var year = currentTime.getFullYear()

var hours = currentTime.getHours()

var minutes = currentTime.getMinutes()

if (minutes < 10){

minutes = "0" + minutes

}

document.write(month + "/" + day + "/" + year + " " + hours + ":" + minutes + " ")

if(hours > 11){

document.write("PM")

} else {

document.write("AM")

}

//-->

</script>

</b>

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Current date can be displayed in javascript embedded in HTML. Creating an object of date will help to show the current date.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How to display current date in html using javascript?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a UNIX command to display the current date in the form ddmmyyyy?

UNIX command to display the current datedate +'%d/%m/%Y'Niraj sharma


Write a program that display the current date of the system using C programming language and ALP?

#include &lt;stdio.h&gt; #include &lt;time.h&gt; void main() { time_t t; time(&amp;t); clrscr(); printf("Today's date and time :\n %s",ctime(&amp;t)); getch(); }


How you can validate tha current date in vc?

The current date does not need validation; it can be read directly from the system clock. However, validating a date against the system clock does not guarantee that date is current; it is only current when the system clock is set correctly.


How can i clear flash player and java script error on you tube?

Any flash or JavaScript errors can be caused in a number of ways. Most of the time, it should be the website's fault if you receive a JavaScript or Flash Player error. Those will correct themselves over-time. But if you receive errors that you know nobody else (Or very few people) receive(s), then the problem could be on your end. Either your JavaScript, or flash player (or both), may be out of date and need to be upgraded. JavaScript can be updated by updating your browser. Flash Players can be updated by going to the Adobe website.


Command to view the value of variable in javascript?

Inside your Javascript (wherever is appropriate) //First get an expires date... var today = new Date(); //right now. var expires = new Date(); //These are the values the cookies gonna end up with var cookieName = 'nameOfTheCookie'; var cookieValue = 'Value'; var nDays = 1; //or whatever number of days you want the cookie to live for expires.setTime(today.getTime() + 3600000*24*nDays); document.cookie = cookieName+' = '+cookieValue+'; expires='+expires.toGMTString()+'; path=/';

Related questions

Insert date on a webpage using javascript?

Just use new Date(); to get the current date and then use document.getElementById to insert it on the webpage. &lt;div id="example"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; document.getElementById('example') = new Date(); &lt;/script&gt;


How do you display the date and time using HTML?

HTML can't get the time for you, so the best way to do it is to use Javascript inside your page, like this: &lt;script language="javascript"&gt; &lt;!-- today = new Date(); document.write("&lt;BR&gt;The time now is: ", today.getHours(),":",today.getMinutes()); document.write("&lt;BR&gt;The date is: ", today.getDate(),"/",today.getMonth()+1,"/",today.getYear()); //--&gt; &lt;/script&gt; Copy and paste that into your web page code. It will show you the date and time.


Write a UNIX command to display the current date in the form ddmmyyyy?

UNIX command to display the current datedate +'%d/%m/%Y'Niraj sharma


Which symbol may be used in an Excel formula to display current date?

The TODAY() function displays the current date. If you want to put the current date into a cell, press the Ctrl and the semi-colon key.


Write a UNIX command to display the current date in the form 02?

date +"%d/%m/%y" date +"%d/%m/%y"


How do you display the current-date in a Wordpad document in any particular format?

Pick Insert, and then Date and you could choose from a list of formats.


How to get the current date of the computer using java?

Date d = new Date(); String s = d.toString(); //the s variable has the current date and time correct to a millisecond


Which websites have information about the JavaScript date object?

There are a lot of websites which have information about the JavaScript date object. However, it is strongly suggested that one should check out from the website W3Schools.


What is a date stamp in excel?

It show the current date on the spreadsheet, and can include the time if you want. Using a few different functions you can display it, depending on what detail you want: =NOW() =TODAY() =TEXT(TODAY(),"d-mmmm-yyyy") &amp; " " &amp; TEXT(NOW(),"h:mm AM/PM")


Write a program that display the current date of the system using C programming language and ALP?

#include &lt;stdio.h&gt; #include &lt;time.h&gt; void main() { time_t t; time(&amp;t); clrscr(); printf("Today's date and time :\n %s",ctime(&amp;t)); getch(); }


What is the shortcut to enter the date in Excel?

The formula is =NOW(). Ensure you format the cell to display the date format you want.


If you have an excel template with automatic date you want that the saved document dont change the date only the template do is there a formula?

I you have a worksheet that updates the date in a cell to the current date, edit the cell to change to the date you want displayed. Most likely, the cell is using the formula =NOW() or some other date function to automatically assign a date to the worksheet. When you replace the formula with the date you want to display, your date will remain until you change it.