Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getDate for a period?

Status
Not open for further replies.

PS1983

Technical User
Nov 6, 2001
83
AT
hello folks, my problem is:

my boss wants me to have our website changed every season, and every Special day like Labour day and stuff!

well its pretty easy with a constant day and month
here my code

Code:
function shiftsource()
	{
		jetzt=new Date();
		Tage = jetzt.getDate();
		Monate = jetzt.getMonth();
		if (Tage == 1 && Monate == 4) window.location.href="index_mai.html";
		if (Tage == 21 && Monate == 2 >= Tage == 21 && Monate ==5) window.location.href="index_sommer.html";
	}

so the index_sommer.html should be from 21 of march to the 21 of june can u help me i'm not good at that == => && stuff thanks in advance
 
<script>
var now = new Date();
var beginSommer = new Date(&quot;03/21/&quot; + now.getFullYear());
var endSommer = new Date(&quot;06/21/&quot; + now.getFullYear());
alert((beginSommer < now) && (now < endSommer));
</script>
 
thx for the answer but i got it working with cases:)

Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
	<title>Shift Resource-Page mit Javascript: Switch()</title>



<script language=&quot;JavaScript&quot;>
 function shiftresmitswitch()
 	{
		jetzt=new Date();
		Tage = jetzt.getDate();
		Monate = jetzt.getMonth() + 1;
		switch(Monate)
			{
				case 1:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->
					window.location.href=&quot;index_winter.html&quot;;
					break;
				case 2:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->
					alert(&quot;Winter&quot;);
					break;
				case 3:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->
					if (Tage >= 21) alert (&quot;Frühling&quot;);
					else alert(&quot;Winter&quot;);
					break;
				case 4:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->
					alert (&quot;Frühling&quot;)
					break;
				case 5:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->
					if (Tage == 1) 
						{
							alert (&quot;Heute ist 1.MAI!!!&quot;);
							break;
						}
					<!-- Wie hier das obige: 1.Mai, kann man auch staffeln, sprich mehrere Abfragen/Monat... // -->
					alert (&quot;Frühling&quot;);
					break;
				case 6:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->
					if (Tage >= 21) alert (&quot;Sommer&quot;);
					else alert(&quot;Frühling&quot;);
					break;
				case 7:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->				
					alert (&quot;Sommer&quot;);
					break;
				case 8:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->				
					alert (&quot;Sommer&quot;)
					break;
				case 9:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->				
					if (Tage == 12) 
						{
							alert (&quot;Heute ist Elmars Geburtstag!!!&quot;);
							break;
						}
					if (Tage >= 23) alert (&quot;Herbst&quot;);
					else alert(&quot;Sommer&quot;);
					break;
				case 10:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->				
					alert (&quot;Herbst&quot;);
					break;
				case 11:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->				
					alert (&quot;Herbst&quot;);
					break;
				case 12:
					<!-- Hier die Abfragen auf ein bestimmtes Datum // -->				
					if (Tage >= 21) alert (&quot;Winter&quot;);
					else alert(&quot;Herbst&quot;);
					break;
			}
	}

	<!-- Statt alert (...) solltest du halt immer window.location.href verwenden... //-->
</script>
</head>
<body onload=&quot;shiftresmitswitch();&quot;>
</body>
</html>
[\code]

cu Stefan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top