Display Dynamic Date


display a Dynamic Date in html page that automatically update

Display Dynamic Date



Hi Friends,

some times we are working with HTML pages , here i give a example to show dynamic date on HTML Page



Followed this code inside html page





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Show Date </title>
</head>

<body onLoad="goforit()">
<script>
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym <10)
daym="0"+daym

//change font size here
var cdate=" <small> <font color='000000' face='Arial'> <b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year
+" </b> </font> </small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

</script>
<span id="clock"> </span>
</body>
</html>


Attachments

  • Display Dynamic Date (38566-2622-date.html)
  • Related Articles

    More articles: Javascript display date Display Dynamic Date Javascript function

    Comments

    Author: Phagu Mahato18 Jan 2014 Member Level: Gold   Points : 4

    Thanks for sharing code about display date




    Display Current date in Web Page


    current date is : <%= Date() %>.


    Another program for display date , month and year









  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: