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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript for a date check

Status
Not open for further replies.

chaddu1256

IS-IT--Management
Jan 13, 2003
28
0
0
US
I was wondering if someone can help me. Im trying to write some javascript that will help me check the system date versus a set date to determine a true or false value.

Basically what I want to happen is when someone clicks on a button I want it to check the system date, and if it is before the 15th of the month then go to one webpage, but if it is after the 15th then go to another webpage.

If anyone could help me with some javascript that will do this I would greatly appreciate it.
 
here ya go:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]

<html>
<head>
<title>Untitled</title>

<script language="javascript"><!--

function doDateCheck() {
    var today = new Date();
    var fifteenth = new Date();
    
    fifteenth.setDate(15);
    
    if (today < fifteenth) window.location = "[URL unfurl="true"]http://www.beforethefifteenth.com/";[/URL]
    else window.location = "[URL unfurl="true"]http://www.afterthefifteenth.com/";[/URL]
}

onload=doDateCheck;

--></script>

</head>

<body>

</body>
</html>

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top