The output will be like this:
And the required code, to be added is this:
<script language="Javascript">
<!--
var dayName = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
var monName = new Array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
var now = new Date
document.write("Today is " + dayName[now.getDay()] + ", " + monName[now.getMonth()] + " "+now.getDate() +".")
//-->
</script>
There's an even simpler code, to display date(like this):
Here's the code:
<script language="Javascript">And to show current time in text format, like this:
<!--
var now = new Date
document.write(now.getDate() + "/" + now.getMonth() + "/" + now.getYear())
//-->
</script>
Add this code:
<script>
atoj = new Date();
atoj1= atoj.getHours();
atoj2 = atoj.getMinutes();
atoj3= atoj.getSeconds();
if(atoj1==0){atoj4=" AM";atoj1=12}
else if(atoj1 <= 11){atoj4=" AM"} else if(atoj1 == 12){atoj4=" PM";atoj1=12} else if(atoj1 >= 13){atoj4=" PM";atoj1-=12}
if(atoj2 <= 9){atoj2="0"+atoj2} document.write(""+atoj1+":"+atoj2+":"+atoj3+""+atoj4+""+"");
</script>



























7 comments:
Thanks for the code. I translated days and months in my own language.
cool ;) !
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
Ann
http://externallaptop.net
Man, how do I change the color of the date?
Hello Felix,
You have to add two more lines of code to any of the above code, like this:
<span style="color: red;">
CODE FOR DATE/TIME HERE
</span>
How do I change the time zone for the clock and date?
You don't have to do that, this script automatically takes the date from the computer where the site is being viewed, so every visitor will automatically see the time/date of his/her own time zone.
Allowed HTML tags: <b>, <i> and <a>
Join and share your views with other bloggers at BloggerStop Community
Comment Like This! and Optimize your blog...
SPAMMER OF THE MONTH: www[.]Seeking4Hosting[.]com