If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Display month & last sunday of month. Help with my code

Hello. I've been struggling with a bit of javascript. I need to display 'current month' and 'date of last Sunday in a month'

Here's what I have so far. I'm getting closer. I can write the date of last sunday of the month but I can't seem to get the current month to display properly.

Example: for this month I want the code to display January 27 but I'm getting December 27. 27 IS the correct date because 27 is the last Sunday in this month but (obviously) I need it to display January because Januuary IS the current month.

Users who have thanked lucky7 for this post:

Yes, that will do it. Thanks lucky. I was hoping to combine the two bits of code into one script. IE Display current month AND the date of the last Sunday (27) in the current month. Having it in one piece of code will not really be necessary. This will do just fine.

Users who have thanked Philip M for this post:

Well if that God Save the Queen is Johnny & Sid's version I know that one too! Thanks for all your help. Got me out of a perplexing issue. document.write obsolete? Oh brother ... it's working for my purposes in this instance so I will not temp fate at this time. Cheers.

document.write obsolete? Oh brother ... it's working for my purposes in this instance so I will not temp fate at this time. Cheers.

Netscape 3 is the most recent browser where there isn't a better way to interact with the web page from JavaScript than to use document.write so it has effectively been obsolete since that browser died 10+ years ago.

With all current browsers you can use either innerHTML which resolves most of the problems that document.write had or you can use the many DOM commands that make up about 60% of JavaScript that even get around the few problems that still exist with innerHTML.

No one should be being taught document.write any more as even browser dinosaurs such as Netscape 4 and IE4 had their own far better ways of interacting with the web page from JavaScript.