Show Todays Date And Current Time As Simple Text On Your Blog

Show Todays Date And Current Time As Simple Text On Your BlogHere’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:


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 for that:

<script language=”Javascript”>
<!–

var now = new Date

document.write(now.getDate() + “/” + now.getMonth() + “/” + now.getYear())

//–>
</script>

Leave a Reply

18 Comments on "Show Todays Date And Current Time As Simple Text On Your Blog"

Notify of
avatar
Sort by:   newest | oldest | most voted
Sam
Guest

Thanks for the code. I translated days and months in my own language.

View Comment
bikes
Guest

cool 😉 !

View Comment
lillian
Guest

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

View Comment
Felix
Guest

Man, how do I change the color of the date?

View Comment
Divya Sai
Guest

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>

View Comment
snam
Guest

How do I change the time zone for the clock and date?

View Comment
Sai - Blogger Widgets
Guest

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.

View Comment
Totlacherin
Guest

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

View Comment
AALUNGA
Guest

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

View Comment
Gurappa
Guest

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…..!

http://WWW.eceinjntu.blogspot.com

View Comment
Anonymous
Guest

Thanks for this.

How can I bold it?

View Comment
Tomate Joyeuse
Guest

Hello, I would like to put the date as a calender like you show on this tutorial. But where is the javascript?

View Comment
Anonymous
Guest

Hi.. how do i enlarge the font size ???

View Comment
Anonymous
Guest

Really nice and simple!

Any chance of a 24 hour clock version?

Thx.

View Comment
Afsal
Guest

How to add year in first code please?

View Comment
Nikhil Ranka
Guest

tried adding the first code in my post template but of no use..please help.I want the date to appear in my post template(i.e when i write a new post the date format as in the first code must be there)

View Comment
CartoonSteve
Guest

Looking for a html widget like this – but shows the day of the week. BTW your anti robot test is too hard to read.

View Comment
dark wizard
Guest

I have tried to combine the first and second way to get the format: "27 August 2012".
but what I find in this year is "27 Agust 113".
Then I changed the code "getDay" to "getFullYear" and succeed. 🙂
thank you

View Comment
wpDiscuz