/    Sign up×
Community /Pin to ProfileBookmark

Display content based on time

Is it possible to use javascript to display content at a certain time each week? For instance if it’s 12:00 PM – 2:00 PM on Monday then a certain string of text appears, otherwise an alternative message appears.

Or would this require php?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliAug 30.2005 — this may be done by JavaScript.

Here is how

when the page loads,

check for current time and date.(Date object)

if its the time you are looking for then display a string, may be by making use of

message = "set new message";

if its no t

message = "alternate message";

document.getElementById("messageDisplayer").innerHTML=message

Hope this helps yuo..:-)
Copy linkTweet thisAlerts:
@jeffy777authorAug 30.2005 — I was thinking that I want the message display to be based on a specified time zone, so I would have to use php since javascript would base it on the client side time zone.
×

Success!

Help @jeffy777 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.6,
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,
)...