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>



























13 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.
My blog is in Spanish and I modified the first code for it to fit the language... it was just a try... and it worked. Thanks a lot.
If you want to see the result, this is it. http://palabrasalasecho.blogspot.com
Thank you very much for the code..
I had been loooking for it so long and just found your method..
Thank you very much!!
Posted in my language Tamil:
aalunga.blogspot.com
hi everyone but i need to show the Standard time on my site as some system may have wrong time so they will see the wrong time na.....!
WWW.eceinjntu.blogspot.com
Thanks for this.
How can I bold it?
Hello, I would like to put the date as a calender like you show on this tutorial. But where is the javascript?
Hi.. how do i enlarge the font size ???
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[.]MensItaly[.]com