Jump to content

Weekly text


Sevir
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...