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

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() +”.”)


There’s an even simpler code, to display date(like this):

Here’s the code:

<script language=”Javascript”>

var now = new Date

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


And to show current time in text format, like this:

atoj = new Date();
atoj1= atoj.getHours();
atoj2 = atoj.getMinutes();
atoj3= atoj.getSeconds();

if(atoj1==0){atoj4=” AM”;atoj1=12}
else if(atoj1 = 13){atoj4=” PM”;atoj1-=12}


18 thoughts on “Show Todays Date And Current Time As Simple Text On Your Blog

  1. 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.

  2. 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:

  3. 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)

  4. 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

Leave a Reply

Your email address will not be published. Required fields are marked *