Jump to content

Weekly text


Sevir

Recommended Posts

One way to do this is to have a array of 52 different srting/messages and then calculate the week number from the current date and display the message. say if Feb 5, 2007 is the 6th week of the year. so arr[6] = "This is the week of vodka" and feb 12th is 7th week and arr[7] = "This is the week of rum"

Link to comment
Share on other sites

Take a look at this page if you need some help with any of the various Date functions in java script:http://www.w3schools.com/jsref/jsref_obj_date.aspJust keep in mind that getMonth() returns the month in a zero-based way. That is to say, the first month of the year (January) will be 0 while the 12th month (December) will be 11. This is useful if you have an array of strings because arrays are also zero-based:

var messages = new Array();messages[0] = "vodka";  // January's messagemessages[1] = "grogg";messages[2] = "aquavit";messages[3] = "wine";...messages[11] = "gin"; // December's messagevar date = new Date();var month = date.getMonth();alert("This is the month of " + messages[month] + "!");

There aren't any getWeek() methods built into the Date object in javascript. If you want to get the current week, you'll have to figure that out on your own or do a search on Google.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...