Show content based on day & time

Hi Experts

I'm developing a site that needs to only show content every Sunday between 1800 & 2100.

How would I do this?

Andy
LVL 3
Andy GreenAsked:
Who is Participating?
 
BuggyCoderCommented:
In Global.asax do this:-

void Application_BeginRequest(object sender, EventArgs e)
{
var dateTime = DateTime.Now;
 var hour = dateTime.Hour;
if(!((dateTime.DayOfWeek==DayOfWeek.Sunday) &&(hour>=18 && hour<21)))
{
Server.Transfer("NotWorking.htm");
}
}

Open in new window

0
 
Andy GreenAuthor Commented:
Thanks, it was thsi I needed: - dateTime.DayOfWeek==DayOfWeek.Sunday

Andy
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.