/    Sign up×
Community /Pin to ProfileBookmark

info based on the day of week

I just want a variable that is based on the day of week. my intention is to have a random picture come up on the page, but only show certain pictures on certain days. I can pick a random number, say 1-10, and then if it’s monday i want it to display mon5.jpg, or mon8.jpg, and tuesday would be tue3.jpg or you get the idea. What is the simpelist way to do this? Thanks.

MasterZ

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@JuuitchanDec 02.2004 — <i>
</i>var wkdaynum=(new Date().getDay());
var wkdaylist='sunmontuewedthufrisat';
var wkdayname=wkdaylist.substring(wkdaynum*3,wkdaynum*3+3);
alert(wkdayname);


Try this out to see what it does.

This is a beginning. You take it from here.
Copy linkTweet thisAlerts:
@MasterZauthorDec 02.2004 — that did it, thanks.
×

Success!

Help @MasterZ 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 5.3,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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