It's Sean!

UK freelance journalist, author
and copywriter Sean McManus

Printed from © Sean McManus.
Home > Articles > Webmaster resources > Javascript Toolkit > Javascript examples > Dates

The Javascript smart marketing toolkit

Javascript date handling toolkit

The date handling features of the toolkit can be used to automate seasonal promotions and weekly promotions.

They can also be used to add a bit more life to your copy, by making it respond to the time.

A time-responsive message like "Why not come down tomorrow - we're open until 10pm on a Saturday and it's not too late to phone us today to make a reservation" becomes easy to program. Site visitors can focus on what's relevant now instead of scanning pages of text for the same information.

The time and date used are those set on the visitor's computer

Table explaining date functions of the toolkit
function what it does example code
the_hour() Returns the hour from the time now (24 hour clock)

if (the_hour()<12) {document.write("Good morning!");} else if (the_hour()<18) {document.write("Good afternoon!");} else document.write("Good evening!");

the_minute() Returns the minute from the time now See example for the_second()
the_second() Returns the second from the time now

document.write("The time is ",the_hour(),":", the_minute(),":",the_second());

the_date() Returns today's date

document.write("Today's date:",day_name(the_day())," ",the_date()," ",month_name(the_month()));

the_day() Returns the day of the week, where 0 is Sunday and 6 is Saturday

if (the_day()==6 || the_day()==0) { document.write("Spoil yourself this weekend!"); } else document.write("Relax - you've been working hard today");

day_name() Returns the name of a given day, where 0 is Sunday and 6 is Saturday

document.write("Today is ",day_name(the_day()));

the_month() Returns the month number, where 0 is January and 11 is December

if (the_month()==11) {document.write("Seasons greetings!");}

month_name() Returns the name of a given month, where 0 is January and 11 is December

document.write("This ",month_name(the_month())," why not take a weekend break?");

countdown(month,day) Displays on screen the number of days remaining until a given date where 0 is January

countdown(11,25); document.write(" until Christmas Day");

Cycling banner advert

See the page on banner cycling features of the toolkit for more information on what this is doing and how it works.

Navigating the toolkit: