ADVERTISEMENTS
Show Present Date And Current Time any where On Your Blog
Here's a simple JavaScript to show the current date anywhere in the blog. You can place this code either in any HTML/JavaScript widget, or anywhere else in the template as per you wish.
The output will be like this:
Today is Tuesday, January 13.
And the required code, to be added is as shown below:
There's an even simpler code, to display date(like this):
13/0/2009
Here's the code:
And to show current time in text format, like this:
6:30:41 AM
Add this code:
The output will be like this:
Today is Tuesday, January 13.
And the required code, to be added is as shown below:
<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("<span style="font-weight: bold; color: rgb(255, 0, 0);">Today is</span> " + dayName[now.getDay()] + ", " + monName[now.getMonth()] + " "+now.getDate() +".")
//-->
</script>
There's an even simpler code, to display date(like this):
13/0/2009
Here's the code:
<script language="Javascript">
<!--
var now = new Date
document.write(now.getDate() + "/" + now.getMonth() + "/" + now.getYear())
//-->
</script>
And to show current time in text format, like this:
6:30:41 AM
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>
0 comments