Tuesday, July 6, 2010

How To Add Date To Web Page Or Blog

Posted: 13 Apr 2010 03:39 AM PDT

In this tutorial I am going to help you to add dynamically current date in your blog/webpage. This will help you make your livelier.

We’ll be using Javascript to initiate the current date and time.

.getDay(), .getMonth(), .getDate(), .getFullYear() functions will be calling the current day, date, month and year.

We’ll be using the help of variable d for new date. Variable weekday will have maximum Array, 7 which is the number of days in a week and variable month with maximum array 12.

Then we are defining each days in weekday[X]=Name of Day.

Similary for month mnth[X]=Name of month serially

After the variables have been addressed we’ll be calling javascript to get current date using document.write() function.

For example, (“” + weekday[d.getDay()]); will call current Day in numerical format starting from 0 as Sunday and 6 as Saturday.

Same goes for the month as well.

When the codes are properly arranged you’ll get the javascript code enclosed in

Tada… this code works individually in any browser.

If you don’t have time, just copy the above code and paste it where you want.

View Demo Here

Hope you liked it. Keep visiting Hackspc for more interesting articles like this.

No comments:

Post a Comment