/    Sign up×
Community /Pin to ProfileBookmark

Check date display text

I am looking for a script that checks the current date and then displays text depending on the date. Basically I want to be able to display a different line of text each day on a web page automatically. Does this make sense to any one and can any one help?

thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliOct 24.2003 — var today = new Date();

the above will give you todays date from your system.

then create an array with seven values representing each day of the week(by default Sunday = 0 index in the array)

and then retrieve the string depending upon the day

dataArray[today.getDay()]
Copy linkTweet thisAlerts:
@pyroOct 24.2003 — Something like this will display a different bit of text for each day of the month:

<script type="text/javascript">

text = new Array("day one", "day two", "day three", "day four", "day five", "day six", "day seven", "day eight", "day nine", "day ten",

"day eleven", "day twelve", "day thirteen", "day fourteen", "day fifteen", "day sixteen", "day seventeen", "day eighteen", "day nineteen", "day twenty",

"day twenty-one", "day twenty-two", "day twenty-three", "day twenty-four", "day twenty-five", "day twenty-six", "day twenty-seven", "day twenty-eight", "day twenty-nine", "day thirty", "thirty-one");

alert (text[new Date().getDate()-1]);

</script>
×

Success!

Help @daveo1 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.20,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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