/    Sign up×
Community /Pin to ProfileBookmark

hi i have this simple script that displays the current date

<SCRIPT LANGUAGE=”JavaScript1.2″>
var months=new Array(13);
months[1]=”January”;
months[2]=”February”;
months[3]=”March”;
months[4]=”April”;
months[5]=”May”;
months[6]=”June”;
months[7]=”July”;
months[8]=”August”;
months[9]=”September”;
months[10]=”October”;
months[11]=”November”;
months[12]=”December”;
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
document.write(“” + lmonth + ” “);
document.write(date + “, ” + year + “”);
</SCRIPT>

i was wondering would it be possible for it to do something like this

if date=(08/08/03) document.write(‘Its My Birthday’);
if date=(25/12/03) document.write(‘Merry Christmas’)

so i can have a whole list of if date=(x) and they are displayed only if the current date matches one on the if dates

Thanks
Rich

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@CharlesOct 07.2003 — [font=monospace]<script type="text/javascript">

<!--

Date.prototype.toDateString = function () {return [this.getDate(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] [this.getMonth()], this.getFullYear()].join(' ')}

daysOfNote = new Object();

daysOfNote['5 May 2003'] = 'My Birthday';

daysOfNote['25 December 2003'] = 'Christmas';

daysOfNote['7 October 2003'] = 'Today';

document.write(new Date().toDateString(), daysOfNote[new Date().toDateString()] ? ', ' + daysOfNote[new Date().toDateString()] : '');

// -->

</script>[/font]
Copy linkTweet thisAlerts:
@96turnerriauthorOct 07.2003 — thanks very much [B]Charles[/B] works a treat, thanks again

Rich
Copy linkTweet thisAlerts:
@96turnerriauthorOct 07.2003 — one more thing for 3 or 4 days of the year, there are two birthdays on the same day, i have tried

daysOfNote['14 Sep 2003'] = 'Mr. B Birthday';

daysOfNote['14 Sep 2003'] = 'Mrs. X Birthday';

but this doesnt seem to work, anyway of fixing that?

Thanks

Rich
Copy linkTweet thisAlerts:
@CharlesOct 07.2003 — [font=monospace]daysOfNote['14 Sep 2003'] = 'Mr. B Birthday and Mrs. X Birthday';[/font]
Copy linkTweet thisAlerts:
@96turnerriauthorOct 07.2003 — o my god, how stupid am i thanks again
×

Success!

Help @96turnerri spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...