SlideShare a Scribd company logo
1 of 22
<HTML>
<HEAD>
<TITLE>The JavaScript Source: Math Related: Date Difference</TITLE>
<META HTTP-EQUIV="The JavaScript Source" CONTENT = "no-cache">
<META NAME="date" CONTENT="2000-09-09">
<META NAME="channel" CONTENT="Web Developer">
<META NAME="author" CONTENT="Ronnie T. Moore">
<META NAME="section" CONTENT="Math Related">
<META NAME="description" CONTENT="Enter two dates (including the time!) and
this script will display the number of weeks, days, hours, minutes, and seconds
between the two. The seconds field is optional, too. For an example, try
entering your birthdate and compare it to today's date.">

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function isValidDate(dateStr) {
// Date validation function courtesty of
// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->

// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

var datePat = /^(d{1,2})(/|-)(d{1,2})2(d{4})$/; // requires 4 digit year

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
alert(dateStr + " Date is not in a valid format.")
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false;
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
return false;
   }
}
return true;
}

function isValidTime(timeStr) {
// Time validation function courtesty of
// Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(d{1,2}):(d{2})(:(d{2}))?(s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0 || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using. OK = Standard
Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute < 0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return true;
}

function dateDiff(dateform) {
date1 = new Date();
date2 = new Date();
diff = new Date();

if (isValidDate(dateform.firstdate.value) &&
isValidTime(dateform.firsttime.value)) { // Validates first date
date1temp = new Date(dateform.firstdate.value + " " + dateform.firsttime.value);
date1.setTime(date1temp.getTime());
}
else return false; // otherwise exits

if (isValidDate(dateform.seconddate.value) &&
isValidTime(dateform.secondtime.value)) { // Validates second date
date2temp = new Date(dateform.seconddate.value + " " +
dateform.secondtime.value);
date2.setTime(date2temp.getTime());
}
else return false; // otherwise exits
// sets difference date to difference of first date and second date

diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

timediff = diff.getTime();

weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
timediff -= weeks * (1000 * 60 * 60 * 24 * 7);

days = Math.floor(timediff / (1000 * 60 * 60 * 24));
timediff -= days * (1000 * 60 * 60 * 24);

hours = Math.floor(timediff / (1000 * 60 * 60));
timediff -= hours * (1000 * 60 * 60);

mins = Math.floor(timediff / (1000 * 60));
timediff -= mins * (1000 * 60);

secs = Math.floor(timediff / 1000);
timediff -= secs * 1000;

dateform.difference.value = weeks + " weeks, " + days + " days, " + hours + "
hours, " + mins + " minutes, and " + secs + " seconds";

return false; // form should never submit, returns false
}
// End -->
</script>
</HEAD>

<BODY BGCOLOR=#ffffff vlink=#0000ff>

<BR>
<center>
<script language="JavaScript" type="text/javascript"><!--
function openDescription(ID) {
var url = "http://www.ppcforhosts.com/public/util/description.cfm?id=" + ID;
link =
window.open(url,"newWin","directories=0,height=250,location=0,menubar=0,resizabl
e=1,scrollbars=1,status=0,toolbar=0,width=450");
}
//--></script>
<table cellpadding=10 cellspacing=0 border=0 width="100%">
   <tr><td align=center>
<!-- cdXpo code -->
<center>
<script type="text/javascript"
src="/icom_includes/toolbars/globaltoolbar/scripts/fsmenu_commented.js"></script
>
<script type="text/javascript"
src="/icom_includes/toolbars/globaltoolbar/scripts/menuset.js"></script>
<script type="text/javascript"
src="/icom_includes/toolbars/globaltoolbar/scripts/menusetv2.js"></script>
<script type="text/javascript"
src="/icom_includes/toolbars/globaltoolbar/scripts/menusetv3.js"></script>
<link rel="stylesheet" type="text/css"
href="/icom_includes/toolbars/globaltoolbar/css/listmenu_h.css" />
<link rel="stylesheet" type="text/css"
href="/icom_includes/toolbars/globaltoolbar/css/listmenu_h_settings.css" />
<!-- START TOP TOOLBAR -->
<div id="heightcontainer"></div>

<div style="width: 100%;" id="navitoolbarcontainer">
              <div style="margin: 0px; padding: 0px; width: 100%;">
              <div id="navitile" style="width: 100%;">
                  <div style="padding-left: 0px; margin-left: 0px; padding-top:
5px; padding-right: 5px; float: left; white-space: nowrap;">

                  <a title="View Internet.com - The Network for Technology
Professionals" href="http://www.internet.com/" class="gt"><img alt="Internet.com
- The Network for Technology Professionals"
src="/icom_includes/toolbars/globaltoolbar/img/icom_logo_global.png"
border="0"></a>

                  </div>
                        <ul class="menulist" id="listMenuRoot"
style="height:22px;">
                         <li style="margin-top:0px;">
                          <a class="gt" href="http://www.internet.com/it/"
style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-
decoration:none;"> <b>IT</b> </a>



                          <ul id="listMenu-id-1">
                   <li style="background-
image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg);
background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none; font-weight: bold;"
href="http://www.internet.com/it">internet.com/IT</a></li>
               <li style="background-
image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg);
background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none; font-weight: bold;"
href="http://www.internet.com/cio">internet.com/CIO</a></li>
                   <li style="background-
image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg);
background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none; font-weight: bold;"
href="http://www.internet.com/security">internet.com/Security</a></li>
                   <li style="background-
image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg);
background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none; font-weight: bold;"
href="http://www.internet.com/networking">internet.com/Networking</a></li>
                   <li style="background-
image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg);
background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none; font-weight: bold;"
href="http://www.internet.com/storage">internet.com/Storage</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.bitaplanet.com">bITa Planet</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.cioupdate.com">CIO Update</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.databasejournal.com/">Database Journal</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.datamation.com">Datamation</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.enterpriseitplanet.com/">Enterprise IT Planet</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.enterprisenetworkingplanet.com">Enterprise Networking
Planet</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.enterprisestorageforum.com">Enterprise Storage Forum</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.esecurityplanet.com">eSecurity Planet</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.hardwarecentral.com/">Hardware Central</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.intranetjournal.com">Intranet Journal</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;" href="http://www.isp-
planet.com/">ISP Planet</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.itsmwatch.com">ITSMwatch</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.linuxplanet.com/">Linux Planet</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.opennetworkstoday.com">Open Networks Today</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://serverwatch.internet.com/">ServerWatch</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.voipplanet.com/">VoIP Planet</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.webvideouniverse.com">WebVideoUniverse</a>
                           </li><li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;" href="http://www.wi-
fiplanet.com/">Wi-Fi Planet</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.windrivers.com/">WinDrivers.com</a></li>
                   <li><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/sections/">Network Map</a></li>
                          </ul>
                         </li>

                         <li style="margin-top:0px;">
                          <a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/developer" class="gt"> <b>Developer</b> </a>
                           <ul id="listMenu-id-2">
                   <li style="background-
image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg);
background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none; font-weight: bold;"
href="http://www.internet.com/developer/">internet.com/Developer</a></li>
                   <li><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.15seconds.com/">15 Seconds</a></li>
<li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.4guysfromrolla.com/">4GuysFromRolla.com</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.asp101.com/">ASP101</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.codeguru.com">CodeGuru</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.developer.com">Developer.com</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.devx.com">DevX</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.flashkit.com/">FlashKit.com</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.developer.com/java/">Gamelan</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.jars.com">JARS</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.javascript.com/">JavaScript.com</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://javascriptsource.com/">JavaScriptSource</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.phpbuilder.com/">PHPBuilder.com</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.scriptsearch.com/">ScriptSearch</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.vbforums.com/">VB Forums</a></li>
                           <li><a style="color: #fff; font-size: 9px;   font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.vbwire.com/">VB Wire</a></li>

                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.webdeveloper.com/">WebDeveloper.com</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.webreference.com/">Webreference</a></li>
                   <li><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/sections/">Network Map</a></li>
                          </ul>

                        </li>

                         <li style="margin-top:0px;">
                          <a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.internetnews.com/" class="gt"> <b>News</b> </a>
                           <ul id="listMenu-id-3">
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.internetnews.com/">Internetnews.com</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.linuxtoday.com/">Linux Today</a></li>
                   <li><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/sections/">Network Map</a></li>
                          </ul>
                         </li>


                         <li style="margin-top:0px;"><a style="color: #fff;
font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.smallbusinesscomputing.com/" class="gt"> <b>Small Business</b>
</a>
                           <ul id="listMenu-id-4">
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.ecommerce-guide.com/">Ecommerce Guide</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;" href="http://www.refer-
it.com/">Refer-It</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.smallbusinesscomputing.com/">SmallBusinessComputing</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.webopedia.com/">Webopedia</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.winplanet.com/">WinPlanet</a></li>
                   <li><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/sections/">Network Map</a></li>
                          </ul>
                         </li>


                         <li style="margin-top:0px;"><a style="color: #fff;
font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/personaltechnology/" class="gt"> <b>Personal
Tech</b> </a>

                           <ul id="listMenu-id-5">
                           <li><a style="color: #fff; font-size:   9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.blackberrytoday.com/">BlackBerryToday</a></li>
                           <li><a style="color: #fff; font-size:   9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.jumbo.com/">Jumbo</a></li>
                           <li><a style="color: #fff; font-size:   9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.megapixel.net">Megapixel.net</a></li>
                           <li><a style="color: #fff; font-size:   9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.palmblvd.com/">Palm Boulevard</a></li>
                           <li><a style="color: #fff; font-size:   9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.pdastreet.com/">PDAStreet</a></li>
                           <li><a style="color: #fff; font-size:   9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.pocketpcwire.com/">PocketPCWire</a></li>
                           <li><a style="color: #fff; font-size:   9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.smartphonetoday.com/">Smart Phone Today</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.windowsmobiletoday.com/">WindowsMobileToday</a></li>
                   <li><a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/sections/">Network Map</a></li>
                          </ul>
                         </li>
                        </ul>



                       <ul style="height: 22px;" id="listMenuv2Root"
class="menulistv2">
                        <li style="margin-top:0px;">

                          <a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica;" href="http://www.jupiterevents.com/" class="gt">
Events </a>

                          <ul id="listMenuv2-id-1">
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.jupiterevents.com/">JupiterEvents</a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.jupiterwebcasts.com/">JupiterWebcasts</a></li>
                          </ul>
                         </li>

                         <li style="margin-top:0px;"><a style="color: #fff;
font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.justtechjobs.com" class="gt"> Jobs </a></li>
                         <li style="margin-top:0px;"><a style="color: #fff;
font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.jupitermedia.com/partners/" class="gt"> Partners </a></li>

                         <li style="margin-top:0px;">
                          <a style="color: #fff; font-size: 9px; font-family:
arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/solutions" class="gt"> Solutions </a>
                          <ul id="listMenuv2-id-2">
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/ebook"> eBooks </a></li>
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/video"> Video </a></li>
                          </ul>
                         </li>

                         <li style="margin-top:0px;"><a style="color: #fff;
font-size: 9px; font-family: arial,verdana,helvetica; text-decoration:none;"
href="http://shop.internet.com/" class=""gt> Shop </a></li>


                       </ul>


                        <ul class="menulistv3" id="listMenuv3Root" style="color:
#fff; font-size: 9px; font-family: arial,verdana,helvetica; height: 22px;">
                         <li style="margin-top:0px;"><a class="gt"
href="http://member.internet.com/" style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration:none"> Login </a>


                          <ul id="listMenuv3-id-1">
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://member.internet.com/profile/postal">Manage My Profile</a></li>

                         </ul>



                         </li>
                         <li style="margin-top:0px;"><a style="color: #fff;
font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;"
href="http://member.internet.com/register" class="gt">Register </a>

                           <ul id="listMenuv3-id-2">
                           <li><a style="color: #fff; font-size: 9px; font-
family: arial,verdana,helvetica; text-decoration: none;"
href="http://www.internet.com/WhyJoin">Why Join?</a></li>
                          </ul>


                        </li>


                       </ul>

           <div style="margin-top: 0px;" id="lightgrey">

            <form target="_top"
action="http://search.internet.com/www.jupiterweb.com" method="post">
                  <input value="1" name="IC_Summary" type="hidden">
                  <input value="0" name="IC_StartNumber" type="hidden">
                  <input value="10" name="IC_BatchSize" type="hidden">

                  <input value="50" name="IC_RelevanceThreshold" type="hidden">
                  <input value="all" name="IC_QueryDatabase" type="hidden">
                  <input title="Search Internet.com" onFocus="this.value='';"
class="inputglobal" size="11" name="IC_QueryText" value="" type="text">

                  <input alt="go"
src="/icom_includes/toolbars/globaltoolbar/img/searchgt_button.gif"
name="SUBMIT" value="Find" type="image" align="absmiddle" border="0" height="18"
vspace="2" width="42">
            </form>
            </div>
      </div>
      </div>

      <!--
      <div style="width:100%;">
      <img src="/icom_includes/toolbars/globaltoolbar/img/shad.png"
style="width:100%; height:11px; padding:0px; margin-top:22px;" />
      </div>
      -->
      </div>

   <script src="/icom_includes/footers/scripts/pngadapt.js"
type="text/javascript"></script>


<!-- END TOP TOOLBAR --><IMG
SRC="http://javascript.internet.com/RealMedia/ads/adstream_lx.ads/intm/webdev/ja
vascript.internet.com/math-related/date-
difference.html/651246313/house_ribbon/OasDefault/Testing_GlobalToolbar_1c/globa
ltoolbarE.html/37633764653365303437343530386630?_RM_EMPTY_" WIDTH=2 HEIGHT=2>
<br>
</center>
<!-- cdXpo code -->
   <iframe
src="http://network.business.com/hooprograms/internetcom2b/search.int?
gr=4&stylename=render.xsl&partner=internet11" frameborder="0" height="100"
width="750" scrolling="no" marginheight="0" marginwidth="0"></iframe>
<IMG
SRC="http://javascript.internet.com/RealMedia/ads/adstream_lx.cgi/intm/webdev/ja
vascript.internet.com/math-related/date-difference.html/633696731/468x60-
1/OasDefault/Business.com_67a/internetresources.html/376337646533653034373435303
86630?_RM_EMPTY_" WIDTH=1 HEIGHT=1></td></tr>
</table>

<BR>
<BR>
<table width="100%" cellpadding=0 cellspacing=0 border=0>
<tr><td width="99%" align=center>

<basefont size=3>
<FONT SIZE="+2" FACE="Helvetica,Arial">
<A HREF="http://javascript.internet.com" TARGET="_top"><FONT
COLOR="#0000FF"><b>Home</b></font></A>
<img src="http://javascript.internet.com/img/arrow.gif" height=13 width=7
border=0 alt="}">
<A HREF="./" TARGET="_top"><font color="#FF0000"><b>Math Related</b></font></A>
<img src="http://javascript.internet.com/img/arrow.gif" height=13 width=7
border=0 alt="}">
<FONT COLOR="#006666"><b>Date Difference</b></font></font>
<BR>
<BR>
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td><font FACE="helvetica,arial,geneva">
<br>
<br>
<!-- Description --><!--content_start-->
Enter two dates (including the time!) and this script will display the number
of weeks, days, hours, minutes, and seconds between the two. The seconds field
is optional, too. For an example, try entering your birthdate and compare it to
today's date.
<hr>
</td></tr>
</table>
<!-- Demonstration -->
<center>
<form onSubmit="return dateDiff(this);">
<table>
<tr><td>
<pre>
First Date:   Date: <input type=text name=firstdate value="" size=10
maxlength=10> (MM/DD/YYYY format)
              Time: <input type=text name=firsttime value="" size=10
maxlength=10> (HH:MM:SS format)

Second Date: Date: <input type=text name=seconddate value="" size=10
maxlength=10> (MM/DD/YYYY format)
              Time: <input type=text name=secondtime value="" size=10
maxlength=10> (HH:MM:SS format)

<center><input type=submit value="Calculate Difference!">
Date Difference:<br>
<input type=text name=difference value="" size=60>
</center>
</pre>
</td></tr>
</table>
</form>
</center>
<P>
<P>
<a name="source">
<table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0>
<tr><td BGCOLOR=yellow><font FACE="helvetica,arial,geneva"><b>The JavaScript
Source: Math Related: Date Difference</b>
<p>Simply click inside the window below, use your cursor to highlight the
script, and copy (type Control-c or Apple-c) the script into a new file in your
text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s).
The script is yours!!!
<br><br></font></td></tr>
<tr><td BGCOLOR=yellow ALIGN=CENTER>
<form NAME="copy">

<DIV align="center">
<input type=button value="Highlight All"
onClick="javascript:this.form.txt.focus();this.form.txt.select();">&nbsp;&nbsp;&
nbsp;&nbsp;
<INPUT TYPE="text" NAME="total" VALUE="Script Size: 5.13 KB" size=24>
</DIV>

<textarea NAME="txt" ROWS=20 COLS=75 WRAP=VIRTUAL>

&lt;!-- TWO STEPS TO INSTALL DATE DIFFERENCE:

  1.   Copy the coding into the HEAD of your HTML document
  2.   Add the last code into the BODY of your HTML document   --&gt;

&lt;!-- STEP ONE: Paste this code into the HEAD of your HTML document   --&gt;

&lt;HEAD&gt;

&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- Original: Ronnie T. Moore --&gt;
&lt;!-- Web Site: The JavaScript Source --&gt;

&lt;!-- This script and many more are available free online at --&gt;
&lt;!-- The JavaScript Source!! http://javascript.internet.com --&gt;

&lt;!-- Begin
function isValidDate(dateStr) {
// Date validation function courtesty of
// Sandeep V. Tamhankar (stamhankar@hotmail.com) --&gt;

// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

var datePat = /^(d{1,2})(/|-)(d{1,2})2(d{4})$/; // requires 4 digit year

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
alert(dateStr + " Date is not in a valid format.")
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month &lt; 1 || month &gt; 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}
if (day &lt; 1 || day &gt; 31) {
alert("Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false;
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day&gt;29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!");
return false;
   }
}
return true;
}

function isValidTime(timeStr) {
// Time validation function courtesty of
// Sandeep V. Tamhankar (stamhankar@hotmail.com) --&gt;

// Checks if time is in HH:MM:SS AM/PM format.
// The seconds and AM/PM are optional.

var timePat = /^(d{1,2}):(d{2})(:(d{2}))?(s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);
if (matchArray == null) {
alert("Time is not in a valid format.");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour &lt; 0 || hour &gt; 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for military time)");
return false;
}
if (hour &lt;= 12 && ampm == null) {
if (confirm("Please indicate which time format you are using. OK = Standard
Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if (hour &gt; 12 && ampm != null) {
alert("You can't specify AM or PM for military time.");
return false;
}
if (minute &lt; 0 || minute &gt; 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second &lt; 0 || second &gt; 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return true;
}

function dateDiff(dateform) {
date1 = new Date();
date2 = new Date();
diff = new Date();

if (isValidDate(dateform.firstdate.value) &&
isValidTime(dateform.firsttime.value)) { // Validates first date
date1temp = new Date(dateform.firstdate.value + " " + dateform.firsttime.value);
date1.setTime(date1temp.getTime());
}
else return false; // otherwise exits

if (isValidDate(dateform.seconddate.value) &&
isValidTime(dateform.secondtime.value)) { // Validates second date
date2temp = new Date(dateform.seconddate.value + " " +
dateform.secondtime.value);
date2.setTime(date2temp.getTime());
}
else return false; // otherwise exits

// sets difference date to difference of first date and second date

diff.setTime(Math.abs(date1.getTime() - date2.getTime()));

timediff = diff.getTime();

weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7));
timediff -= weeks * (1000 * 60 * 60 * 24 * 7);

days = Math.floor(timediff / (1000 * 60 * 60 * 24));
timediff -= days * (1000 * 60 * 60 * 24);

hours = Math.floor(timediff / (1000 * 60 * 60));
timediff -= hours * (1000 * 60 * 60);

mins = Math.floor(timediff / (1000 * 60));
timediff -= mins * (1000 * 60);

secs = Math.floor(timediff / 1000);
timediff -= secs * 1000;

dateform.difference.value = weeks + " weeks, " + days + " days, " + hours + "
hours, " + mins + " minutes, and " + secs + " seconds";

return false; // form should never submit, returns false
}
// End --&gt;
&lt;/script&gt;
&lt;/HEAD&gt;

&lt;!-- STEP TWO: Copy this code into the BODY of your HTML document   --&gt;

&lt;BODY&gt;

&lt;center&gt;
&lt;form onSubmit="return dateDiff(this);"&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;
&lt;pre&gt;
First Date:   Date: &lt;input type=text name=firstdate value="" size=10
maxlength=10&gt; (MM/DD/YYYY format)
              Time: &lt;input type=text name=firsttime value="" size=10
maxlength=10&gt; (HH:MM:SS format)

Second Date: Date: &lt;input type=text name=seconddate value="" size=10
maxlength=10&gt; (MM/DD/YYYY format)
              Time: &lt;input type=text name=secondtime value="" size=10
maxlength=10&gt; (HH:MM:SS format)

&lt;center&gt;&lt;input type=submit value="Calculate Difference!"&gt;

Date Difference:&lt;br&gt;
&lt;input type=text name=difference value="" size=60&gt;
&lt;/center&gt;
&lt;/pre&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/center&gt;

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

&lt;!-- Script Size: 5.13 KB --&gt;</textarea><br><font
FACE="helvetica,arial,geneva"><a href="http://javascript.internet.com/link-
us.html">Did you use this script?&nbsp;&nbsp;Do you like this site?
&nbsp;&nbsp;Please link to us!</a></font></td></tr>

</table>
</form>
<!--content_stop-->

<p>

<td>
<!--   Begin 125X800 Ad Code   -->
<style type="text/css">

/* =shopbanneritems
----------------------------------------------- */
#shopicomsky a{
  margin:0px;
  padding:0;
  color:#333;
  margin-bottom: 0px;
  margin-top: 0px;
  background-color: transparent;
  }


#shopicomsky a:hover{
  text-decoration: none;
  }

#shopicomsky p{
  margin-top: 5px;
  margin-bottom: 5px;
  margin-top: expression('10px');
margin-bottom: expression('10px');
  background-color: transparent;

  }


</style>


<table cellpadding="0" cellspacing="0" border="0" width="125">
<tr>
<td colspan="3"><a href="http://shop.internet.com/"><img
src="http://www.internet.com/icom_includes/special/dealtime/img/sicom_logo.gif"
width="125" height="23" border="0"></a></td>
</tr>
<tr>
<td colspan="3">
<img
src="http://www.internet.com/icom_includes/special/dealtime/img/compare.gif"
width="125" height="15"></td>
</tr>
<tr>
<td bgcolor="#d31820" colspan="3" align="center" nowrap>
<table width="125" cellpadding="0" cellspacing="0" border="0">
<tr>
<form method="GET" action="http://shop.internet.com/index.php" target="_top">
<td align="center">
<input type="hidden" name="IC_ic" value="1">
<input type="hidden" name="IC_query_search" value="1">

<input type="text" value="Search here" size="10" class="shad"
NAME="IC_QueryText" onFocus="this.value='';" style="margin: 2px;"/>
</td>
<td><input type="image"
src="http://www.internet.com/icom_includes/special/dealtime/img/go2.gif"
border=0 WIDTH="27" HEIGHT="17"></td>
</form>
</table>
</td>
</tr>
<tr>
<tr>
<td align="center" bgcolor="#ffffff" style="border: 1px solid #CC0033; padding-
bottom: 2px;">


<div align="center" id="shopicomsky" bgcolor="#ffffff">
<script type="text/javascript" src='http://shop.internet.com/search.php?
format=125x600_1&keyword=RAM'></script>
</div>

</td>
</tr>
</table><IMG
SRC="http://javascript.internet.com/RealMedia/ads/adstream_lx.cgi/intm/webdev/ja
vascript.internet.com/math-related/date-
difference.html/959985430/125x800/OasDefault/DealTime_67zh/random_125x800_shop.h
tml/37633764653365303437343530386630?_RM_EMPTY_" WIDTH=1 HEIGHT=1>
<!--   End 125X800 Ad Code -->
</td></tr>
</table>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function getCookieVal (offset) {
var endstr = document.cookie.indexOf(";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0)
break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = "/"; //(argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" +
expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

var emailcookie = GetCookie('email_address');
if (emailcookie == null) {
emailcookie = 'your email here';
}

function chk(email, formname)
{
invalid = "";

if (!email)
invalid = "No email address found!   Try reloading the page then use the 'email a
script' feature again.";

else {

if ( (email.indexOf("@") == -1) || (email.indexOf(".") == -1) )
invalid += "nnInvalid email address. Your email address is missing an '@'
sign and a '.' in the domain name (like '.com'). Please check your address then
submit again.";

if (email.indexOf("youremailhere") > -1)
invalid += "nnInvalid email address. Make sure your email address included
your username, the '@' sign, and the domain name (like '.com').";

if (email.indexOf("") > -1)
invalid += "nnEmail address contains an invalid back-slash () character.
Remove the character and submit again.";
if (email.indexOf("/") > -1)
invalid += "nnEmail address contains an invalid forward-slash (/) character.
Remove the character and submit again.";

if (email.indexOf("'") > -1)
invalid += "nnEmail address contains an invalid apostrophe (') character.
Remove the character and submit again.";

if (email.indexOf("zaz.com.br") > -1)
invalid += "nnPlease do not use an email address that has an autoresponder set
up for it. Thanks.";

if (email.indexOf("!") > -1)
invalid += "nnEmail address contains an invalid exclamation point (!)
character. Remove the character or correct the email address then submit
again.";

if ( (email.indexOf(",") > -1) || (email.indexOf(";") > -1) )
invalid += "nnPlease only enter one email address in the box at a time.
Remove the extra addresses and submit again.";

if (email.indexOf("?subject") > -1)
invalid += "nnPlease do not add '?subject=...' to your email address.
Scriptbot will send you the script with a pre-defined subject already. Please
remove the '?subject=...' from your email address and submit again.";
}

if (invalid == "")
   {
   var largeExpDate = new Date();
   largeExpDate.setTime(largeExpDate.getTime() + (31 * 24 * 3600 * 1000));
   SetCookie('email_address', email, largeExpDate);
   if (formname == "scriptbot")
      {
      page = "http://javascript.internet.com/sent.html?" + email;
      window.open(page, "AdWindow", "width=650,height=200");
      }
   return true;
}
else
   {
   alert("Oops, something is wrong...." + invalid);
   return false;
   }
}

function updateNewsletters() {
with (document.forms["newslettersignup"]) {
emailStr = email.value;
var emailPat=/^(.+)@(.+)$/;
var specialChars="()<>@,;:".[]"; // remove   ( ) < > @ , ; : 
" . [ ]    */
var validChars="[^s" + specialChars + "]";
var quotedUser="("[^"]*")";
var ipDomainPat=/^[(d{1,3}).(d{1,3}).(d{1,3}).(d{1,3})]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)");
return false;;
}
var user=matchArray[1];
var domain=matchArray[2];
if (user.match(userPat)==null) {
alert("The username doesn't seem to be valid.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
      }
   }
}
var domainArray=domain.match(domainPat);
if (domainArray==null) {
alert("The domain name doesn't seem to be valid.");
return false;
}
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
alert("The address must end in a three-letter domain, or two letter country.");
return false;
}
if (len<2) {
var errStr="This address is missing a hostname!";
alert(errStr);
return false;
}
List_Name.value = newsletter.options[newsletter.selectedIndex].value
            + nltype.options[nltype.selectedIndex].value;

   var largeExpDate = new Date();
   largeExpDate.setTime(largeExpDate.getTime() + (31 * 24 * 3600 * 1000));
   SetCookie('email_address', emailStr, largeExpDate);

return true;
   }
}
// End -->
</script>

<p>
<center>

<table cellpadding=0 cellspacing=0 border=0 width="620">
<tr>
<td align=left>

<table cellpadding=0 cellspacing=0 border=1 bgcolor=#ffffcc>
<tr><td align=center valign=middle>

<table cellpadding=5 cellspacing=10 border=0 bgcolor=#ffffcc>
<tr><td colspan=4 align=center valign=bottom>
<font face="arial, helvetica" size="-1"><a href="http://e-
newsletters.internet.com/javascriptsource.html">Sign up for the JavaScript
Weekly</a></font></td></tr>
<tr>
<td>

<form action="http://e-newsletters.internet.com/cgi-bin/subscribe" method=POST>
<TABLE>
  <TR>
    <td>
      <FONT SIZE="-1">
      <div align="center"><input type=hidden name="List_Name" value="javascript-
com-html">


      <br>
      <div align="center"><input name="email" size="15"
value="my@email">&nbsp;&nbsp;
      <input type="hidden" name="redirect_ok" value="http://e-
newsletters.internet.com/thankyou_new.html">
      <input type="submit" name="Submit" value="Join"></div>
    </td>
  </TR>
</TABLE>
</form>

</td>
</tr>
</table>
<font face="arial, helvetica" size="-1"><a
href="http://www.internet.com/corporate/privacy/privacypolicy.html">internet.com
Privacy Policy</a></font>
</td></tr></table>


</TD>

<td align=right>

<form name="scriptbot" action="/cgi-bin/scriptbot.cgi" method="POST"
onSubmit="return chk(document.scriptbot.email.value, 'scriptbot')">

<input type=hidden name=filename value='date-difference.html'>

<table border=1 cellspacing=0 cellpadding=20><tr bgcolor=#ebebeb>
<td align=center><tt>We'll send this script to you!<p></tt>
<SCRIPT>
<!-- Begin
document.write('<input type=text size=25 name=email value="'+emailcookie+'"
onFocus="if(this.value=='your email here')this.value=''">');
// End -->
</SCRIPT>

<input type=submit value="Send it!">
<p><font size="-2">(just click "Send it!" once!)</font></td></tr>
</table></form>
</td>
</tr>
<tr>
<td>
</td>
<td align=right><font face="arial" size="-2"><div align=right><span
class="address">
[ <A HREF="http://javascript.internet.com/feedback.html"
ONMOUSEOVER="window.status='Comments, questions, suggestions, or gripes, we want
to hear from you!'; return true" ONMOUSEOUT="window.status=''; return
true">Contact Us!</A> ]<BR>

[ <A HREF="http://www.webdeveloper.com/forum/forumdisplay.php?f=3"
ONMOUSEOVER="window.status='Visit our JavaScript Forum for assistance!'; return
true" ONMOUSEOUT="window.status=' '; return true">JavaScript Forum</A> ]<br>
[ <A HREF="http://javascript.internet.com/contribute/"
ONMOUSEOVER="window.status='Submit your script creation to us and it could be
featured on our site!'; return true" ONMOUSEOUT="window.status=''; return
true">Submit Your Script!</A> ]<p>

</span></div></font></td>
</tr></table>

<DIV ALIGN="CENTER">
<!--   Begin 468X60 Ad Code (750X100 max)     -->

<A
HREF="http://javascript.internet.com/RealMedia/ads/click_lx.cgi/intm/webdev/java
script.internet.com/math-related/date-difference.html/1278067345/468x60-
2/OasDefault/Verio_NovDec07_1e/Verioleocomp1ron.gif/3763376465336530343734353038
6630" target="_top"><IMG
SRC="http://javascript.internet.com/RealMedia/ads/Creatives/OasDefault/Verio_Nov
Dec07_1e/Verioleocomp1ron.gif" ALT="" BORDER="0"></A><img
src="http://javascript.internet.com/RealMedia/ads/adstream_lx.cgi/intm/webdev/ja
vascript.internet.com/math-related/date-difference.html/1278067345/468x60-
2/OasDefault/Verio_NovDec07_1e/Verioleocomp1ron.gif/3763376465336530343734353038
6630?_RM_EMPTY_" Width="1" Height="1" Border="0">

<!--   End 468X60 Ad Code (750X100 max)     -->
</DIV>

<!-- Google Analytics -->
<script src="/icom_includes/footers/scripts/ga.js" type="text/javascript">
</script>
<script type="text/javascript" >
<!--      hide from no js browsers
delete Array.prototype.itemValidation;
delete Array.prototype.isArray;
var superTracker = _gat._getTracker("UA-2838492-1");
superTracker._initData();
superTracker._trackPageview();

-->
</script>
<script type="text/javascript" >
    var site_name = location.hostname;
    if ( site_name.indexOf("www.") != 0 ) {
      site_name = "www."+site_name ;
    }
    document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2'
SRC='/icom_includes/footers/sites/"+ site_name +".js'
TYPE='text/javascript'></SCR" + "IPT>");
-->
</script>
<script type="text/javascript" >
<!--       hide from no js browsers
    pageTracker._initData();
    pageTracker._trackPageview();
    // -->
</script>
<!-- End Google Analytics -->

<script src="/icom_includes/footers/scripts/pngadapt.js"
type="text/javascript"></script>

<BR CLEAR="all"><br><center><table border="0" cellspacing="0" cellpadding="5">
                <tr>
                  <form method="POST"
action="http://search.internet.com/www.jupiterweb.com" target="_top">

                    <td align="center">
<table border="0" class="mgfoot">
  <tr><td class="foot_alt" align="center" style="vertical-align:middle;">
                               <img
src="/icom_includes/footers/onlinemedia_footer.png" alt="JupiterOnlineMedia"
width="175" height="17" hspace="0" border="0">
                      <p align="center">
                      <a target="_blank" href="http://www.internet.com"
class="foot" target="_top"><img src="/icom_includes/footers/icom_foot.png"
alt="internet.com" width="97" height="15" hspace="0" border="0"
align="absmiddle" style="margin-top:expression('-24px');"></a><img
src="/icom_includes/footers/ruledivide_foot.gif" alt="" width="1" height="25"
hspace="10" border="0" align="absmiddle"><a target="_blank"
href="http://www.earthweb.com" target="_top"><img
src="/icom_includes/footers/earthweb_foot.png" alt="earthweb.com" width="93"
height="10" hspace="5" border="0" align="absmiddle" style="margin-
top:expression('-22px');"></a><img
src="/icom_includes/footers/ruledivide_foot.gif" alt="" width="1" height="25"
hspace="10" border="0" align="absmiddle"><a target="_blank"
href="http://www.devx.com" target="_top"><img
src="/icom_includes/footers/devx_foot.png" alt="Devx.com" width="34" height="30"
hspace="0" border="0" align="absmiddle"></a><img
src="/icom_includes/footers/ruledivide_foot.gif" alt="" width="1" height="25"
hspace="10" border="0" align="absmiddle"><a target="_blank"
href="http://www.mediabistro.com" target="_top"><img
src="/icom_includes/footers/mediabistro_foot.png" alt="mediabistro.com"
width="100" height="35" hspace="0" border="0" align="absmiddle"></a><img
src="/icom_includes/footers/ruledivide_foot.gif" alt="" width="1" height="25"
hspace="10" border="0" align="absmiddle"><a target="_blank"
href="http://www.graphics.com" target="_top"><img
src="/icom_includes/footers/grcom_foot.png" alt="Graphics.com" width="97"
height="16" hspace="0" border="0" align="absmiddle" style="margin-
top:expression('-24px');"></a></td></tr></table>
                      <p>
                      <font size="-2" face="verdana, arial,
helvetica"><b>Search:</b>
                      <input type="HIDDEN" name="IC_Summary" value="1">
                      <input type="HIDDEN" name="IC_StartNumber" value="0">

                      <input type="HIDDEN" name="IC_BatchSize" value="10">

                      <input type="HIDDEN" name="IC_RelevanceThreshold"
value="50">
                      <input type="hidden" name="IC_QueryDatabase" value="all">
                      <input type="text" name="IC_QueryText" size="45">
                      <input type="image" border="0" value="Find" name="SUBMIT"
src="/icom_includes/footers/but_find.gif" width="41" height="20"
align="absmiddle">
                      </font>
                      <p>
                      <font size="-2" face="verdana, arial, helvetica">

                     <a target="_blank" href="http://www.jupitermedia.com/"
class="foot"> Jupitermedia Corporation</a> has two divisions: <a target="_blank"
href="http://www.jupiterimages.com/" class="foot">Jupiterimages</a> and <a
target="_blank" href="http://www.jupitermedia.com/onlinemedia.html"
class="foot">JupiterOnlineMedia</a><P> <font size="-2" face="verdana, arial,
helvetica"><a target="_blank" href="http://www.jupitermedia.com/corporate/"
class="foot" target="_top">Jupitermedia Corporate Info</a>
<p>

                      <div class="foot"><!--Copyright 2005-2007-->
<script type="text/javascript">
document.write(' Copyright ');
var now = new Date();
document.write( + now.getFullYear());
document.write(' Jupitermedia Corporation All Rights Reserved.');
</script>
<noscript> Copyright 2007 Jupitermedia Corporation All Rights
Reserved.</noscript>
<br>
                        <a target="_blank"
href="http://www.jupitermedia.com/corporate/legal.html" class="foot"
target="_top">Legal
                        Notices</a>, <a target="_blank"
href="http://www.jupitermedia.com/corporate/reprints.html#Licensing1"
class="foot" target="_top">Licensing</a>,
                        <a target="_blank"
href="http://www.jupitermedia.com/corporate/reprints.html#Reprints1"
class="foot" target="_top">Reprints</a>,
                        & <a target="_blank"
href="http://www.jupitermedia.com/corporate/reprints.html#Permissions"
class="foot" target="_top">Permissions</a>,
                        <a target="_blank"
href="http://www.jupitermedia.com/corporate/privacy/privacypolicy.html"
class="foot" target="_top">Privacy
                        Policy</a>. </font>

                      <p> <font size="-2" face="verdana, arial, helvetica"><a
target="_blank" href="http://www.jupitermedia.com/onlinemedia.html" class="foot"
target="_top">Advertise</a> | <a target="_blank" href="http://e-
newsletters.internet.com/" class="foot">Newsletters</a>
                       | <a target="_blank" href="http://jobs.internet.com/"
class="foot" target="_top">Tech
                        Jobs</a> | <a target="_blank"
href="http://www.internetshopper.com/" class="foot" target="_top">Shopping</a> |
<a target="_blank" href="http://e-
newsletters.internet.com/announcement_list.html" class="foot" target="_top">E-
mail
                        Offers</a></div></font>

                    </td>
                  </form>
                </tr>
              </table></center>



</center>
</body></html>

More Related Content

What's hot

Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESSjsmith92
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & CompassRob Davarnia
 
Componentization css angular
Componentization css angularComponentization css angular
Componentization css angularDavid Amend
 
Building Things Fast - and getting approval
Building Things Fast - and getting approvalBuilding Things Fast - and getting approval
Building Things Fast - and getting approvalSimon Willison
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...Codemotion
 
CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書拓樹 谷
 
Web Development with CoffeeScript and Sass
Web Development with CoffeeScript and SassWeb Development with CoffeeScript and Sass
Web Development with CoffeeScript and SassBrian Hogan
 
2012.sandiego.wordcamp
2012.sandiego.wordcamp2012.sandiego.wordcamp
2012.sandiego.wordcampBrandon Dove
 
Micropage in microtime using microframework
Micropage in microtime using microframeworkMicropage in microtime using microframework
Micropage in microtime using microframeworkRadek Benkel
 
LessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG MeetingLessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG MeetingMyles Braithwaite
 
Responsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da WebResponsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da WebEduardo Shiota Yasuda
 
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011brucelawson
 

What's hot (18)

Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESS
 
Playing With The Web
Playing With The WebPlaying With The Web
Playing With The Web
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
Componentization css angular
Componentization css angularComponentization css angular
Componentization css angular
 
Educacion fisica
Educacion fisicaEducacion fisica
Educacion fisica
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
Building Things Fast - and getting approval
Building Things Fast - and getting approvalBuilding Things Fast - and getting approval
Building Things Fast - and getting approval
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
 
CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書CSSプリプロセッサの取扱説明書
CSSプリプロセッサの取扱説明書
 
Web Development with CoffeeScript and Sass
Web Development with CoffeeScript and SassWeb Development with CoffeeScript and Sass
Web Development with CoffeeScript and Sass
 
2012.sandiego.wordcamp
2012.sandiego.wordcamp2012.sandiego.wordcamp
2012.sandiego.wordcamp
 
Micropage in microtime using microframework
Micropage in microtime using microframeworkMicropage in microtime using microframework
Micropage in microtime using microframework
 
LessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG MeetingLessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG Meeting
 
SlideShare Instant
SlideShare InstantSlideShare Instant
SlideShare Instant
 
SlideShare Instant
SlideShare InstantSlideShare Instant
SlideShare Instant
 
Csharp Intsight
Csharp IntsightCsharp Intsight
Csharp Intsight
 
Responsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da WebResponsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da Web
 
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
You too can be a bedwetting antfucker: Bruce Lawson, Opera, Fronteers 2011
 

Viewers also liked

Sharism,MOOC and future learning
Sharism,MOOC and future learningSharism,MOOC and future learning
Sharism,MOOC and future learningIsaac Mao
 
激发成就(国际讲演会执委培训TLI-1)
激发成就(国际讲演会执委培训TLI-1)激发成就(国际讲演会执委培训TLI-1)
激发成就(国际讲演会执委培训TLI-1)刘 世一
 
讲故事-成功的密码 the art of storytelling
讲故事-成功的密码 the art of storytelling讲故事-成功的密码 the art of storytelling
讲故事-成功的密码 the art of storytellingmartinsun
 
2016 08-04:邁向成功,我的夢想之路
2016 08-04:邁向成功,我的夢想之路2016 08-04:邁向成功,我的夢想之路
2016 08-04:邁向成功,我的夢想之路廣利 姜
 
七个您可能正在犯的错误… 而且是上司绝对不乐见的错误!
七个您可能正在犯的错误… 而且是上司绝对不乐见的错误!七个您可能正在犯的错误… 而且是上司绝对不乐见的错误!
七个您可能正在犯的错误… 而且是上司绝对不乐见的错误!Bjorn Orvar
 
我的朋友一级棒
我的朋友一级棒我的朋友一级棒
我的朋友一级棒Brandon Law
 

Viewers also liked (7)

Sharism,MOOC and future learning
Sharism,MOOC and future learningSharism,MOOC and future learning
Sharism,MOOC and future learning
 
激发成就(国际讲演会执委培训TLI-1)
激发成就(国际讲演会执委培训TLI-1)激发成就(国际讲演会执委培训TLI-1)
激发成就(国际讲演会执委培训TLI-1)
 
Teaching Chinese Through Drama and Song
Teaching Chinese Through Drama and SongTeaching Chinese Through Drama and Song
Teaching Chinese Through Drama and Song
 
讲故事-成功的密码 the art of storytelling
讲故事-成功的密码 the art of storytelling讲故事-成功的密码 the art of storytelling
讲故事-成功的密码 the art of storytelling
 
2016 08-04:邁向成功,我的夢想之路
2016 08-04:邁向成功,我的夢想之路2016 08-04:邁向成功,我的夢想之路
2016 08-04:邁向成功,我的夢想之路
 
七个您可能正在犯的错误… 而且是上司绝对不乐见的错误!
七个您可能正在犯的错误… 而且是上司绝对不乐见的错误!七个您可能正在犯的错误… 而且是上司绝对不乐见的错误!
七个您可能正在犯的错误… 而且是上司绝对不乐见的错误!
 
我的朋友一级棒
我的朋友一级棒我的朋友一级棒
我的朋友一级棒
 

Similar to Date difference[1]

#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup PerformanceJustin Cataldo
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and ImprovedTimothy Fisher
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-KjaerCOMMON Europe
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshowsblackman
 
Being a tweaker modern web performance techniques
Being a tweaker   modern web performance techniquesBeing a tweaker   modern web performance techniques
Being a tweaker modern web performance techniquesChris Love
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosIgor Sobreira
 
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference Zürich
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference ZürichHTML5 and CSS3 – exploring mobile possibilities - Frontend Conference Zürich
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference ZürichRobert Nyman
 
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridasFrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridasLoiane Groner
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventRobert Nyman
 
جيفيرا باي الساحل الشمالي
جيفيرا باي الساحل الشماليجيفيرا باي الساحل الشمالي
جيفيرا باي الساحل الشماليReda Hassan
 
Presentation html5 css3 by thibaut
Presentation html5 css3 by thibautPresentation html5 css3 by thibaut
Presentation html5 css3 by thibautThibaut Baillet
 

Similar to Date difference[1] (20)

Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
 
HTML5
HTML5HTML5
HTML5
 
Borrador del blog
Borrador del blogBorrador del blog
Borrador del blog
 
Web technology lab manual
Web technology lab manualWeb technology lab manual
Web technology lab manual
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
Being a tweaker modern web performance techniques
Being a tweaker   modern web performance techniquesBeing a tweaker   modern web performance techniques
Being a tweaker modern web performance techniques
 
Test upload
Test uploadTest upload
Test upload
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference Zürich
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference ZürichHTML5 and CSS3 – exploring mobile possibilities - Frontend Conference Zürich
HTML5 and CSS3 – exploring mobile possibilities - Frontend Conference Zürich
 
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridasFrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
FrontInBahia 2014: 10 dicas de desempenho para apps mobile híbridas
 
Webtechnology lab
Webtechnology labWebtechnology lab
Webtechnology lab
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
 
جيفيرا باي الساحل الشمالي
جيفيرا باي الساحل الشماليجيفيرا باي الساحل الشمالي
جيفيرا باي الساحل الشمالي
 
ApacheCon 2005
ApacheCon 2005ApacheCon 2005
ApacheCon 2005
 
Presentation html5 css3 by thibaut
Presentation html5 css3 by thibautPresentation html5 css3 by thibaut
Presentation html5 css3 by thibaut
 

Date difference[1]

  • 1. <HTML> <HEAD> <TITLE>The JavaScript Source: Math Related: Date Difference</TITLE> <META HTTP-EQUIV="The JavaScript Source" CONTENT = "no-cache"> <META NAME="date" CONTENT="2000-09-09"> <META NAME="channel" CONTENT="Web Developer"> <META NAME="author" CONTENT="Ronnie T. Moore"> <META NAME="section" CONTENT="Math Related"> <META NAME="description" CONTENT="Enter two dates (including the time!) and this script will display the number of weeks, days, hours, minutes, and seconds between the two. The seconds field is optional, too. For an example, try entering your birthdate and compare it to today's date."> <SCRIPT LANGUAGE="JavaScript"> <!-- Original: Ronnie T. Moore --> <!-- Web Site: The JavaScript Source --> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function isValidDate(dateStr) { // Date validation function courtesty of // Sandeep V. Tamhankar (stamhankar@hotmail.com) --> // Checks for the following valid date formats: // MM/DD/YY MM/DD/YYYY MM-DD-YY MM-DD-YYYY var datePat = /^(d{1,2})(/|-)(d{1,2})2(d{4})$/; // requires 4 digit year var matchArray = dateStr.match(datePat); // is the format ok? if (matchArray == null) { alert(dateStr + " Date is not in a valid format.") return false; } month = matchArray[1]; // parse date into variables day = matchArray[3]; year = matchArray[4]; if (month < 1 || month > 12) { // check month range alert("Month must be between 1 and 12."); return false; } if (day < 1 || day > 31) { alert("Day must be between 1 and 31."); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert("Month "+month+" doesn't have 31 days!") return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day==29 && !isleap)) { alert("February " + year + " doesn't have " + day + " days!"); return false; } } return true; } function isValidTime(timeStr) { // Time validation function courtesty of // Sandeep V. Tamhankar (stamhankar@hotmail.com) -->
  • 2. // Checks if time is in HH:MM:SS AM/PM format. // The seconds and AM/PM are optional. var timePat = /^(d{1,2}):(d{2})(:(d{2}))?(s?(AM|am|PM|pm))?$/; var matchArray = timeStr.match(timePat); if (matchArray == null) { alert("Time is not in a valid format."); return false; } hour = matchArray[1]; minute = matchArray[2]; second = matchArray[4]; ampm = matchArray[6]; if (second=="") { second = null; } if (ampm=="") { ampm = null } if (hour < 0 || hour > 23) { alert("Hour must be between 1 and 12. (or 0 and 23 for military time)"); return false; } if (hour <= 12 && ampm == null) { if (confirm("Please indicate which time format you are using. OK = Standard Time, CANCEL = Military Time")) { alert("You must specify AM or PM."); return false; } } if (hour > 12 && ampm != null) { alert("You can't specify AM or PM for military time."); return false; } if (minute < 0 || minute > 59) { alert ("Minute must be between 0 and 59."); return false; } if (second != null && (second < 0 || second > 59)) { alert ("Second must be between 0 and 59."); return false; } return true; } function dateDiff(dateform) { date1 = new Date(); date2 = new Date(); diff = new Date(); if (isValidDate(dateform.firstdate.value) && isValidTime(dateform.firsttime.value)) { // Validates first date date1temp = new Date(dateform.firstdate.value + " " + dateform.firsttime.value); date1.setTime(date1temp.getTime()); } else return false; // otherwise exits if (isValidDate(dateform.seconddate.value) && isValidTime(dateform.secondtime.value)) { // Validates second date date2temp = new Date(dateform.seconddate.value + " " + dateform.secondtime.value); date2.setTime(date2temp.getTime()); } else return false; // otherwise exits
  • 3. // sets difference date to difference of first date and second date diff.setTime(Math.abs(date1.getTime() - date2.getTime())); timediff = diff.getTime(); weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7)); timediff -= weeks * (1000 * 60 * 60 * 24 * 7); days = Math.floor(timediff / (1000 * 60 * 60 * 24)); timediff -= days * (1000 * 60 * 60 * 24); hours = Math.floor(timediff / (1000 * 60 * 60)); timediff -= hours * (1000 * 60 * 60); mins = Math.floor(timediff / (1000 * 60)); timediff -= mins * (1000 * 60); secs = Math.floor(timediff / 1000); timediff -= secs * 1000; dateform.difference.value = weeks + " weeks, " + days + " days, " + hours + " hours, " + mins + " minutes, and " + secs + " seconds"; return false; // form should never submit, returns false } // End --> </script> </HEAD> <BODY BGCOLOR=#ffffff vlink=#0000ff> <BR> <center> <script language="JavaScript" type="text/javascript"><!-- function openDescription(ID) { var url = "http://www.ppcforhosts.com/public/util/description.cfm?id=" + ID; link = window.open(url,"newWin","directories=0,height=250,location=0,menubar=0,resizabl e=1,scrollbars=1,status=0,toolbar=0,width=450"); } //--></script> <table cellpadding=10 cellspacing=0 border=0 width="100%"> <tr><td align=center> <!-- cdXpo code --> <center> <script type="text/javascript" src="/icom_includes/toolbars/globaltoolbar/scripts/fsmenu_commented.js"></script > <script type="text/javascript" src="/icom_includes/toolbars/globaltoolbar/scripts/menuset.js"></script> <script type="text/javascript" src="/icom_includes/toolbars/globaltoolbar/scripts/menusetv2.js"></script> <script type="text/javascript" src="/icom_includes/toolbars/globaltoolbar/scripts/menusetv3.js"></script> <link rel="stylesheet" type="text/css" href="/icom_includes/toolbars/globaltoolbar/css/listmenu_h.css" /> <link rel="stylesheet" type="text/css" href="/icom_includes/toolbars/globaltoolbar/css/listmenu_h_settings.css" />
  • 4. <!-- START TOP TOOLBAR --> <div id="heightcontainer"></div> <div style="width: 100%;" id="navitoolbarcontainer"> <div style="margin: 0px; padding: 0px; width: 100%;"> <div id="navitile" style="width: 100%;"> <div style="padding-left: 0px; margin-left: 0px; padding-top: 5px; padding-right: 5px; float: left; white-space: nowrap;"> <a title="View Internet.com - The Network for Technology Professionals" href="http://www.internet.com/" class="gt"><img alt="Internet.com - The Network for Technology Professionals" src="/icom_includes/toolbars/globaltoolbar/img/icom_logo_global.png" border="0"></a> </div> <ul class="menulist" id="listMenuRoot" style="height:22px;"> <li style="margin-top:0px;"> <a class="gt" href="http://www.internet.com/it/" style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text- decoration:none;"> <b>IT</b> </a> <ul id="listMenu-id-1"> <li style="background- image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg); background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none; font-weight: bold;" href="http://www.internet.com/it">internet.com/IT</a></li> <li style="background- image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg); background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none; font-weight: bold;" href="http://www.internet.com/cio">internet.com/CIO</a></li> <li style="background- image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg); background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none; font-weight: bold;" href="http://www.internet.com/security">internet.com/Security</a></li> <li style="background- image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg); background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none; font-weight: bold;" href="http://www.internet.com/networking">internet.com/Networking</a></li> <li style="background- image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg); background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none; font-weight: bold;" href="http://www.internet.com/storage">internet.com/Storage</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.bitaplanet.com">bITa Planet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.cioupdate.com">CIO Update</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.databasejournal.com/">Database Journal</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.datamation.com">Datamation</a></li> <li><a style="color: #fff; font-size: 9px; font-
  • 5. family: arial,verdana,helvetica; text-decoration: none;" href="http://www.enterpriseitplanet.com/">Enterprise IT Planet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.enterprisenetworkingplanet.com">Enterprise Networking Planet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.enterprisestorageforum.com">Enterprise Storage Forum</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.esecurityplanet.com">eSecurity Planet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.hardwarecentral.com/">Hardware Central</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.intranetjournal.com">Intranet Journal</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.isp- planet.com/">ISP Planet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.itsmwatch.com">ITSMwatch</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.linuxplanet.com/">Linux Planet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.opennetworkstoday.com">Open Networks Today</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://serverwatch.internet.com/">ServerWatch</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.voipplanet.com/">VoIP Planet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.webvideouniverse.com">WebVideoUniverse</a> </li><li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.wi- fiplanet.com/">Wi-Fi Planet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.windrivers.com/">WinDrivers.com</a></li> <li><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/sections/">Network Map</a></li> </ul> </li> <li style="margin-top:0px;"> <a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/developer" class="gt"> <b>Developer</b> </a> <ul id="listMenu-id-2"> <li style="background- image:url(/icom_includes/toolbars/globaltoolbar/img/background_topsub.jpg); background-repeat:repeat-x;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none; font-weight: bold;" href="http://www.internet.com/developer/">internet.com/Developer</a></li> <li><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.15seconds.com/">15 Seconds</a></li>
  • 6. <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.4guysfromrolla.com/">4GuysFromRolla.com</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.asp101.com/">ASP101</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.codeguru.com">CodeGuru</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.developer.com">Developer.com</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.devx.com">DevX</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.flashkit.com/">FlashKit.com</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.developer.com/java/">Gamelan</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.jars.com">JARS</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.javascript.com/">JavaScript.com</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://javascriptsource.com/">JavaScriptSource</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.phpbuilder.com/">PHPBuilder.com</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.scriptsearch.com/">ScriptSearch</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.vbforums.com/">VB Forums</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.vbwire.com/">VB Wire</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.webdeveloper.com/">WebDeveloper.com</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.webreference.com/">Webreference</a></li> <li><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/sections/">Network Map</a></li> </ul> </li> <li style="margin-top:0px;"> <a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internetnews.com/" class="gt"> <b>News</b> </a> <ul id="listMenu-id-3"> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;"
  • 7. href="http://www.internetnews.com/">Internetnews.com</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.linuxtoday.com/">Linux Today</a></li> <li><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/sections/">Network Map</a></li> </ul> </li> <li style="margin-top:0px;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.smallbusinesscomputing.com/" class="gt"> <b>Small Business</b> </a> <ul id="listMenu-id-4"> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.ecommerce-guide.com/">Ecommerce Guide</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.refer- it.com/">Refer-It</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.smallbusinesscomputing.com/">SmallBusinessComputing</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.webopedia.com/">Webopedia</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.winplanet.com/">WinPlanet</a></li> <li><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/sections/">Network Map</a></li> </ul> </li> <li style="margin-top:0px;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/personaltechnology/" class="gt"> <b>Personal Tech</b> </a> <ul id="listMenu-id-5"> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.blackberrytoday.com/">BlackBerryToday</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.jumbo.com/">Jumbo</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.megapixel.net">Megapixel.net</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.palmblvd.com/">Palm Boulevard</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.pdastreet.com/">PDAStreet</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.pocketpcwire.com/">PocketPCWire</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;"
  • 8. href="http://www.smartphonetoday.com/">Smart Phone Today</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.windowsmobiletoday.com/">WindowsMobileToday</a></li> <li><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/sections/">Network Map</a></li> </ul> </li> </ul> <ul style="height: 22px;" id="listMenuv2Root" class="menulistv2"> <li style="margin-top:0px;"> <a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica;" href="http://www.jupiterevents.com/" class="gt"> Events </a> <ul id="listMenuv2-id-1"> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.jupiterevents.com/">JupiterEvents</a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.jupiterwebcasts.com/">JupiterWebcasts</a></li> </ul> </li> <li style="margin-top:0px;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.justtechjobs.com" class="gt"> Jobs </a></li> <li style="margin-top:0px;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.jupitermedia.com/partners/" class="gt"> Partners </a></li> <li style="margin-top:0px;"> <a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/solutions" class="gt"> Solutions </a> <ul id="listMenuv2-id-2"> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/ebook"> eBooks </a></li> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/video"> Video </a></li> </ul> </li> <li style="margin-top:0px;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration:none;" href="http://shop.internet.com/" class=""gt> Shop </a></li> </ul> <ul class="menulistv3" id="listMenuv3Root" style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; height: 22px;"> <li style="margin-top:0px;"><a class="gt" href="http://member.internet.com/" style="color: #fff; font-size: 9px; font-
  • 9. family: arial,verdana,helvetica; text-decoration:none"> Login </a> <ul id="listMenuv3-id-1"> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://member.internet.com/profile/postal">Manage My Profile</a></li> </ul> </li> <li style="margin-top:0px;"><a style="color: #fff; font-size: 9px; font-family: arial,verdana,helvetica; text-decoration: none;" href="http://member.internet.com/register" class="gt">Register </a> <ul id="listMenuv3-id-2"> <li><a style="color: #fff; font-size: 9px; font- family: arial,verdana,helvetica; text-decoration: none;" href="http://www.internet.com/WhyJoin">Why Join?</a></li> </ul> </li> </ul> <div style="margin-top: 0px;" id="lightgrey"> <form target="_top" action="http://search.internet.com/www.jupiterweb.com" method="post"> <input value="1" name="IC_Summary" type="hidden"> <input value="0" name="IC_StartNumber" type="hidden"> <input value="10" name="IC_BatchSize" type="hidden"> <input value="50" name="IC_RelevanceThreshold" type="hidden"> <input value="all" name="IC_QueryDatabase" type="hidden"> <input title="Search Internet.com" onFocus="this.value='';" class="inputglobal" size="11" name="IC_QueryText" value="" type="text"> <input alt="go" src="/icom_includes/toolbars/globaltoolbar/img/searchgt_button.gif" name="SUBMIT" value="Find" type="image" align="absmiddle" border="0" height="18" vspace="2" width="42"> </form> </div> </div> </div> <!-- <div style="width:100%;"> <img src="/icom_includes/toolbars/globaltoolbar/img/shad.png" style="width:100%; height:11px; padding:0px; margin-top:22px;" /> </div> --> </div> <script src="/icom_includes/footers/scripts/pngadapt.js" type="text/javascript"></script> <!-- END TOP TOOLBAR --><IMG
  • 10. SRC="http://javascript.internet.com/RealMedia/ads/adstream_lx.ads/intm/webdev/ja vascript.internet.com/math-related/date- difference.html/651246313/house_ribbon/OasDefault/Testing_GlobalToolbar_1c/globa ltoolbarE.html/37633764653365303437343530386630?_RM_EMPTY_" WIDTH=2 HEIGHT=2> <br> </center> <!-- cdXpo code --> <iframe src="http://network.business.com/hooprograms/internetcom2b/search.int? gr=4&stylename=render.xsl&partner=internet11" frameborder="0" height="100" width="750" scrolling="no" marginheight="0" marginwidth="0"></iframe> <IMG SRC="http://javascript.internet.com/RealMedia/ads/adstream_lx.cgi/intm/webdev/ja vascript.internet.com/math-related/date-difference.html/633696731/468x60- 1/OasDefault/Business.com_67a/internetresources.html/376337646533653034373435303 86630?_RM_EMPTY_" WIDTH=1 HEIGHT=1></td></tr> </table> <BR> <BR> <table width="100%" cellpadding=0 cellspacing=0 border=0> <tr><td width="99%" align=center> <basefont size=3> <FONT SIZE="+2" FACE="Helvetica,Arial"> <A HREF="http://javascript.internet.com" TARGET="_top"><FONT COLOR="#0000FF"><b>Home</b></font></A> <img src="http://javascript.internet.com/img/arrow.gif" height=13 width=7 border=0 alt="}"> <A HREF="./" TARGET="_top"><font color="#FF0000"><b>Math Related</b></font></A> <img src="http://javascript.internet.com/img/arrow.gif" height=13 width=7 border=0 alt="}"> <FONT COLOR="#006666"><b>Date Difference</b></font></font> <BR> <BR> <table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0> <tr><td><font FACE="helvetica,arial,geneva"> <br> <br> <!-- Description --><!--content_start--> Enter two dates (including the time!) and this script will display the number of weeks, days, hours, minutes, and seconds between the two. The seconds field is optional, too. For an example, try entering your birthdate and compare it to today's date. <hr> </td></tr> </table> <!-- Demonstration --> <center> <form onSubmit="return dateDiff(this);"> <table> <tr><td> <pre> First Date: Date: <input type=text name=firstdate value="" size=10 maxlength=10> (MM/DD/YYYY format) Time: <input type=text name=firsttime value="" size=10 maxlength=10> (HH:MM:SS format) Second Date: Date: <input type=text name=seconddate value="" size=10 maxlength=10> (MM/DD/YYYY format) Time: <input type=text name=secondtime value="" size=10 maxlength=10> (HH:MM:SS format) <center><input type=submit value="Calculate Difference!">
  • 11. Date Difference:<br> <input type=text name=difference value="" size=60> </center> </pre> </td></tr> </table> </form> </center> <P> <P> <a name="source"> <table BORDER=0 WIDTH=486 CELLPADDING=3 CELLSPACING=0> <tr><td BGCOLOR=yellow><font FACE="helvetica,arial,geneva"><b>The JavaScript Source: Math Related: Date Difference</b> <p>Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!! <br><br></font></td></tr> <tr><td BGCOLOR=yellow ALIGN=CENTER> <form NAME="copy"> <DIV align="center"> <input type=button value="Highlight All" onClick="javascript:this.form.txt.focus();this.form.txt.select();">&nbsp;&nbsp;& nbsp;&nbsp; <INPUT TYPE="text" NAME="total" VALUE="Script Size: 5.13 KB" size=24> </DIV> <textarea NAME="txt" ROWS=20 COLS=75 WRAP=VIRTUAL> &lt;!-- TWO STEPS TO INSTALL DATE DIFFERENCE: 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --&gt; &lt;!-- STEP ONE: Paste this code into the HEAD of your HTML document --&gt; &lt;HEAD&gt; &lt;SCRIPT LANGUAGE="JavaScript"&gt; &lt;!-- Original: Ronnie T. Moore --&gt; &lt;!-- Web Site: The JavaScript Source --&gt; &lt;!-- This script and many more are available free online at --&gt; &lt;!-- The JavaScript Source!! http://javascript.internet.com --&gt; &lt;!-- Begin function isValidDate(dateStr) { // Date validation function courtesty of // Sandeep V. Tamhankar (stamhankar@hotmail.com) --&gt; // Checks for the following valid date formats: // MM/DD/YY MM/DD/YYYY MM-DD-YY MM-DD-YYYY var datePat = /^(d{1,2})(/|-)(d{1,2})2(d{4})$/; // requires 4 digit year var matchArray = dateStr.match(datePat); // is the format ok? if (matchArray == null) { alert(dateStr + " Date is not in a valid format.") return false; } month = matchArray[1]; // parse date into variables
  • 12. day = matchArray[3]; year = matchArray[4]; if (month &lt; 1 || month &gt; 12) { // check month range alert("Month must be between 1 and 12."); return false; } if (day &lt; 1 || day &gt; 31) { alert("Day must be between 1 and 31."); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert("Month "+month+" doesn't have 31 days!") return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day&gt;29 || (day==29 && !isleap)) { alert("February " + year + " doesn't have " + day + " days!"); return false; } } return true; } function isValidTime(timeStr) { // Time validation function courtesty of // Sandeep V. Tamhankar (stamhankar@hotmail.com) --&gt; // Checks if time is in HH:MM:SS AM/PM format. // The seconds and AM/PM are optional. var timePat = /^(d{1,2}):(d{2})(:(d{2}))?(s?(AM|am|PM|pm))?$/; var matchArray = timeStr.match(timePat); if (matchArray == null) { alert("Time is not in a valid format."); return false; } hour = matchArray[1]; minute = matchArray[2]; second = matchArray[4]; ampm = matchArray[6]; if (second=="") { second = null; } if (ampm=="") { ampm = null } if (hour &lt; 0 || hour &gt; 23) { alert("Hour must be between 1 and 12. (or 0 and 23 for military time)"); return false; } if (hour &lt;= 12 && ampm == null) { if (confirm("Please indicate which time format you are using. OK = Standard Time, CANCEL = Military Time")) { alert("You must specify AM or PM."); return false; } } if (hour &gt; 12 && ampm != null) { alert("You can't specify AM or PM for military time."); return false; } if (minute &lt; 0 || minute &gt; 59) { alert ("Minute must be between 0 and 59."); return false;
  • 13. } if (second != null && (second &lt; 0 || second &gt; 59)) { alert ("Second must be between 0 and 59."); return false; } return true; } function dateDiff(dateform) { date1 = new Date(); date2 = new Date(); diff = new Date(); if (isValidDate(dateform.firstdate.value) && isValidTime(dateform.firsttime.value)) { // Validates first date date1temp = new Date(dateform.firstdate.value + " " + dateform.firsttime.value); date1.setTime(date1temp.getTime()); } else return false; // otherwise exits if (isValidDate(dateform.seconddate.value) && isValidTime(dateform.secondtime.value)) { // Validates second date date2temp = new Date(dateform.seconddate.value + " " + dateform.secondtime.value); date2.setTime(date2temp.getTime()); } else return false; // otherwise exits // sets difference date to difference of first date and second date diff.setTime(Math.abs(date1.getTime() - date2.getTime())); timediff = diff.getTime(); weeks = Math.floor(timediff / (1000 * 60 * 60 * 24 * 7)); timediff -= weeks * (1000 * 60 * 60 * 24 * 7); days = Math.floor(timediff / (1000 * 60 * 60 * 24)); timediff -= days * (1000 * 60 * 60 * 24); hours = Math.floor(timediff / (1000 * 60 * 60)); timediff -= hours * (1000 * 60 * 60); mins = Math.floor(timediff / (1000 * 60)); timediff -= mins * (1000 * 60); secs = Math.floor(timediff / 1000); timediff -= secs * 1000; dateform.difference.value = weeks + " weeks, " + days + " days, " + hours + " hours, " + mins + " minutes, and " + secs + " seconds"; return false; // form should never submit, returns false } // End --&gt; &lt;/script&gt; &lt;/HEAD&gt; &lt;!-- STEP TWO: Copy this code into the BODY of your HTML document --&gt; &lt;BODY&gt; &lt;center&gt; &lt;form onSubmit="return dateDiff(this);"&gt;
  • 14. &lt;table&gt; &lt;tr&gt;&lt;td&gt; &lt;pre&gt; First Date: Date: &lt;input type=text name=firstdate value="" size=10 maxlength=10&gt; (MM/DD/YYYY format) Time: &lt;input type=text name=firsttime value="" size=10 maxlength=10&gt; (HH:MM:SS format) Second Date: Date: &lt;input type=text name=seconddate value="" size=10 maxlength=10&gt; (MM/DD/YYYY format) Time: &lt;input type=text name=secondtime value="" size=10 maxlength=10&gt; (HH:MM:SS format) &lt;center&gt;&lt;input type=submit value="Calculate Difference!"&gt; Date Difference:&lt;br&gt; &lt;input type=text name=difference value="" size=60&gt; &lt;/center&gt; &lt;/pre&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/center&gt; <p><center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> &lt;!-- Script Size: 5.13 KB --&gt;</textarea><br><font FACE="helvetica,arial,geneva"><a href="http://javascript.internet.com/link- us.html">Did you use this script?&nbsp;&nbsp;Do you like this site? &nbsp;&nbsp;Please link to us!</a></font></td></tr> </table> </form> <!--content_stop--> <p> <td> <!-- Begin 125X800 Ad Code --> <style type="text/css"> /* =shopbanneritems ----------------------------------------------- */ #shopicomsky a{ margin:0px; padding:0; color:#333; margin-bottom: 0px; margin-top: 0px; background-color: transparent; } #shopicomsky a:hover{ text-decoration: none; } #shopicomsky p{ margin-top: 5px; margin-bottom: 5px; margin-top: expression('10px');
  • 15. margin-bottom: expression('10px'); background-color: transparent; } </style> <table cellpadding="0" cellspacing="0" border="0" width="125"> <tr> <td colspan="3"><a href="http://shop.internet.com/"><img src="http://www.internet.com/icom_includes/special/dealtime/img/sicom_logo.gif" width="125" height="23" border="0"></a></td> </tr> <tr> <td colspan="3"> <img src="http://www.internet.com/icom_includes/special/dealtime/img/compare.gif" width="125" height="15"></td> </tr> <tr> <td bgcolor="#d31820" colspan="3" align="center" nowrap> <table width="125" cellpadding="0" cellspacing="0" border="0"> <tr> <form method="GET" action="http://shop.internet.com/index.php" target="_top"> <td align="center"> <input type="hidden" name="IC_ic" value="1"> <input type="hidden" name="IC_query_search" value="1"> <input type="text" value="Search here" size="10" class="shad" NAME="IC_QueryText" onFocus="this.value='';" style="margin: 2px;"/> </td> <td><input type="image" src="http://www.internet.com/icom_includes/special/dealtime/img/go2.gif" border=0 WIDTH="27" HEIGHT="17"></td> </form> </table> </td> </tr> <tr> <tr> <td align="center" bgcolor="#ffffff" style="border: 1px solid #CC0033; padding- bottom: 2px;"> <div align="center" id="shopicomsky" bgcolor="#ffffff"> <script type="text/javascript" src='http://shop.internet.com/search.php? format=125x600_1&keyword=RAM'></script> </div> </td> </tr> </table><IMG SRC="http://javascript.internet.com/RealMedia/ads/adstream_lx.cgi/intm/webdev/ja vascript.internet.com/math-related/date- difference.html/959985430/125x800/OasDefault/DealTime_67zh/random_125x800_shop.h tml/37633764653365303437343530386630?_RM_EMPTY_" WIDTH=1 HEIGHT=1> <!-- End 125X800 Ad Code --> </td></tr> </table> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin
  • 16. function getCookieVal (offset) { var endstr = document.cookie.indexOf(";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = "/"; //(argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } var emailcookie = GetCookie('email_address'); if (emailcookie == null) { emailcookie = 'your email here'; } function chk(email, formname) { invalid = ""; if (!email) invalid = "No email address found! Try reloading the page then use the 'email a script' feature again."; else { if ( (email.indexOf("@") == -1) || (email.indexOf(".") == -1) ) invalid += "nnInvalid email address. Your email address is missing an '@' sign and a '.' in the domain name (like '.com'). Please check your address then submit again."; if (email.indexOf("youremailhere") > -1) invalid += "nnInvalid email address. Make sure your email address included your username, the '@' sign, and the domain name (like '.com')."; if (email.indexOf("") > -1) invalid += "nnEmail address contains an invalid back-slash () character. Remove the character and submit again.";
  • 17. if (email.indexOf("/") > -1) invalid += "nnEmail address contains an invalid forward-slash (/) character. Remove the character and submit again."; if (email.indexOf("'") > -1) invalid += "nnEmail address contains an invalid apostrophe (') character. Remove the character and submit again."; if (email.indexOf("zaz.com.br") > -1) invalid += "nnPlease do not use an email address that has an autoresponder set up for it. Thanks."; if (email.indexOf("!") > -1) invalid += "nnEmail address contains an invalid exclamation point (!) character. Remove the character or correct the email address then submit again."; if ( (email.indexOf(",") > -1) || (email.indexOf(";") > -1) ) invalid += "nnPlease only enter one email address in the box at a time. Remove the extra addresses and submit again."; if (email.indexOf("?subject") > -1) invalid += "nnPlease do not add '?subject=...' to your email address. Scriptbot will send you the script with a pre-defined subject already. Please remove the '?subject=...' from your email address and submit again."; } if (invalid == "") { var largeExpDate = new Date(); largeExpDate.setTime(largeExpDate.getTime() + (31 * 24 * 3600 * 1000)); SetCookie('email_address', email, largeExpDate); if (formname == "scriptbot") { page = "http://javascript.internet.com/sent.html?" + email; window.open(page, "AdWindow", "width=650,height=200"); } return true; } else { alert("Oops, something is wrong...." + invalid); return false; } } function updateNewsletters() { with (document.forms["newslettersignup"]) { emailStr = email.value; var emailPat=/^(.+)@(.+)$/; var specialChars="()<>@,;:".[]"; // remove ( ) < > @ , ; : " . [ ] */ var validChars="[^s" + specialChars + "]"; var quotedUser="("[^"]*")"; var ipDomainPat=/^[(d{1,3}).(d{1,3}).(d{1,3}).(d{1,3})]$/; var atom=validChars + '+'; var word="(" + atom + "|" + quotedUser + ")"; var userPat=new RegExp("^" + word + "(." + word + ")*$"); var domainPat=new RegExp("^" + atom + "(." + atom +")*$"); var matchArray=emailStr.match(emailPat); if (matchArray==null) { alert("Email address seems incorrect (check @ and .'s)"); return false;; }
  • 18. var user=matchArray[1]; var domain=matchArray[2]; if (user.match(userPat)==null) { alert("The username doesn't seem to be valid."); return false; } var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Destination IP address is invalid!"); return false; } } } var domainArray=domain.match(domainPat); if (domainArray==null) { alert("The domain name doesn't seem to be valid."); return false; } var atomPat=new RegExp(atom,"g"); var domArr=domain.match(atomPat); var len=domArr.length; if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) { alert("The address must end in a three-letter domain, or two letter country."); return false; } if (len<2) { var errStr="This address is missing a hostname!"; alert(errStr); return false; } List_Name.value = newsletter.options[newsletter.selectedIndex].value + nltype.options[nltype.selectedIndex].value; var largeExpDate = new Date(); largeExpDate.setTime(largeExpDate.getTime() + (31 * 24 * 3600 * 1000)); SetCookie('email_address', emailStr, largeExpDate); return true; } } // End --> </script> <p> <center> <table cellpadding=0 cellspacing=0 border=0 width="620"> <tr> <td align=left> <table cellpadding=0 cellspacing=0 border=1 bgcolor=#ffffcc> <tr><td align=center valign=middle> <table cellpadding=5 cellspacing=10 border=0 bgcolor=#ffffcc> <tr><td colspan=4 align=center valign=bottom> <font face="arial, helvetica" size="-1"><a href="http://e- newsletters.internet.com/javascriptsource.html">Sign up for the JavaScript Weekly</a></font></td></tr> <tr> <td> <form action="http://e-newsletters.internet.com/cgi-bin/subscribe" method=POST>
  • 19. <TABLE> <TR> <td> <FONT SIZE="-1"> <div align="center"><input type=hidden name="List_Name" value="javascript- com-html"> <br> <div align="center"><input name="email" size="15" value="my@email">&nbsp;&nbsp; <input type="hidden" name="redirect_ok" value="http://e- newsletters.internet.com/thankyou_new.html"> <input type="submit" name="Submit" value="Join"></div> </td> </TR> </TABLE> </form> </td> </tr> </table> <font face="arial, helvetica" size="-1"><a href="http://www.internet.com/corporate/privacy/privacypolicy.html">internet.com Privacy Policy</a></font> </td></tr></table> </TD> <td align=right> <form name="scriptbot" action="/cgi-bin/scriptbot.cgi" method="POST" onSubmit="return chk(document.scriptbot.email.value, 'scriptbot')"> <input type=hidden name=filename value='date-difference.html'> <table border=1 cellspacing=0 cellpadding=20><tr bgcolor=#ebebeb> <td align=center><tt>We'll send this script to you!<p></tt> <SCRIPT> <!-- Begin document.write('<input type=text size=25 name=email value="'+emailcookie+'" onFocus="if(this.value=='your email here')this.value=''">'); // End --> </SCRIPT> <input type=submit value="Send it!"> <p><font size="-2">(just click "Send it!" once!)</font></td></tr> </table></form> </td> </tr> <tr> <td> </td> <td align=right><font face="arial" size="-2"><div align=right><span class="address"> [ <A HREF="http://javascript.internet.com/feedback.html" ONMOUSEOVER="window.status='Comments, questions, suggestions, or gripes, we want to hear from you!'; return true" ONMOUSEOUT="window.status=''; return true">Contact Us!</A> ]<BR> [ <A HREF="http://www.webdeveloper.com/forum/forumdisplay.php?f=3" ONMOUSEOVER="window.status='Visit our JavaScript Forum for assistance!'; return true" ONMOUSEOUT="window.status=' '; return true">JavaScript Forum</A> ]<br>
  • 20. [ <A HREF="http://javascript.internet.com/contribute/" ONMOUSEOVER="window.status='Submit your script creation to us and it could be featured on our site!'; return true" ONMOUSEOUT="window.status=''; return true">Submit Your Script!</A> ]<p> </span></div></font></td> </tr></table> <DIV ALIGN="CENTER"> <!-- Begin 468X60 Ad Code (750X100 max) --> <A HREF="http://javascript.internet.com/RealMedia/ads/click_lx.cgi/intm/webdev/java script.internet.com/math-related/date-difference.html/1278067345/468x60- 2/OasDefault/Verio_NovDec07_1e/Verioleocomp1ron.gif/3763376465336530343734353038 6630" target="_top"><IMG SRC="http://javascript.internet.com/RealMedia/ads/Creatives/OasDefault/Verio_Nov Dec07_1e/Verioleocomp1ron.gif" ALT="" BORDER="0"></A><img src="http://javascript.internet.com/RealMedia/ads/adstream_lx.cgi/intm/webdev/ja vascript.internet.com/math-related/date-difference.html/1278067345/468x60- 2/OasDefault/Verio_NovDec07_1e/Verioleocomp1ron.gif/3763376465336530343734353038 6630?_RM_EMPTY_" Width="1" Height="1" Border="0"> <!-- End 468X60 Ad Code (750X100 max) --> </DIV> <!-- Google Analytics --> <script src="/icom_includes/footers/scripts/ga.js" type="text/javascript"> </script> <script type="text/javascript" > <!-- hide from no js browsers delete Array.prototype.itemValidation; delete Array.prototype.isArray; var superTracker = _gat._getTracker("UA-2838492-1"); superTracker._initData(); superTracker._trackPageview(); --> </script> <script type="text/javascript" > var site_name = location.hostname; if ( site_name.indexOf("www.") != 0 ) { site_name = "www."+site_name ; } document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='/icom_includes/footers/sites/"+ site_name +".js' TYPE='text/javascript'></SCR" + "IPT>"); --> </script> <script type="text/javascript" > <!-- hide from no js browsers pageTracker._initData(); pageTracker._trackPageview(); // --> </script> <!-- End Google Analytics --> <script src="/icom_includes/footers/scripts/pngadapt.js" type="text/javascript"></script> <BR CLEAR="all"><br><center><table border="0" cellspacing="0" cellpadding="5"> <tr> <form method="POST"
  • 21. action="http://search.internet.com/www.jupiterweb.com" target="_top"> <td align="center"> <table border="0" class="mgfoot"> <tr><td class="foot_alt" align="center" style="vertical-align:middle;"> <img src="/icom_includes/footers/onlinemedia_footer.png" alt="JupiterOnlineMedia" width="175" height="17" hspace="0" border="0"> <p align="center"> <a target="_blank" href="http://www.internet.com" class="foot" target="_top"><img src="/icom_includes/footers/icom_foot.png" alt="internet.com" width="97" height="15" hspace="0" border="0" align="absmiddle" style="margin-top:expression('-24px');"></a><img src="/icom_includes/footers/ruledivide_foot.gif" alt="" width="1" height="25" hspace="10" border="0" align="absmiddle"><a target="_blank" href="http://www.earthweb.com" target="_top"><img src="/icom_includes/footers/earthweb_foot.png" alt="earthweb.com" width="93" height="10" hspace="5" border="0" align="absmiddle" style="margin- top:expression('-22px');"></a><img src="/icom_includes/footers/ruledivide_foot.gif" alt="" width="1" height="25" hspace="10" border="0" align="absmiddle"><a target="_blank" href="http://www.devx.com" target="_top"><img src="/icom_includes/footers/devx_foot.png" alt="Devx.com" width="34" height="30" hspace="0" border="0" align="absmiddle"></a><img src="/icom_includes/footers/ruledivide_foot.gif" alt="" width="1" height="25" hspace="10" border="0" align="absmiddle"><a target="_blank" href="http://www.mediabistro.com" target="_top"><img src="/icom_includes/footers/mediabistro_foot.png" alt="mediabistro.com" width="100" height="35" hspace="0" border="0" align="absmiddle"></a><img src="/icom_includes/footers/ruledivide_foot.gif" alt="" width="1" height="25" hspace="10" border="0" align="absmiddle"><a target="_blank" href="http://www.graphics.com" target="_top"><img src="/icom_includes/footers/grcom_foot.png" alt="Graphics.com" width="97" height="16" hspace="0" border="0" align="absmiddle" style="margin- top:expression('-24px');"></a></td></tr></table> <p> <font size="-2" face="verdana, arial, helvetica"><b>Search:</b> <input type="HIDDEN" name="IC_Summary" value="1"> <input type="HIDDEN" name="IC_StartNumber" value="0"> <input type="HIDDEN" name="IC_BatchSize" value="10"> <input type="HIDDEN" name="IC_RelevanceThreshold" value="50"> <input type="hidden" name="IC_QueryDatabase" value="all"> <input type="text" name="IC_QueryText" size="45"> <input type="image" border="0" value="Find" name="SUBMIT" src="/icom_includes/footers/but_find.gif" width="41" height="20" align="absmiddle"> </font> <p> <font size="-2" face="verdana, arial, helvetica"> <a target="_blank" href="http://www.jupitermedia.com/" class="foot"> Jupitermedia Corporation</a> has two divisions: <a target="_blank" href="http://www.jupiterimages.com/" class="foot">Jupiterimages</a> and <a target="_blank" href="http://www.jupitermedia.com/onlinemedia.html" class="foot">JupiterOnlineMedia</a><P> <font size="-2" face="verdana, arial, helvetica"><a target="_blank" href="http://www.jupitermedia.com/corporate/" class="foot" target="_top">Jupitermedia Corporate Info</a> <p> <div class="foot"><!--Copyright 2005-2007-->
  • 22. <script type="text/javascript"> document.write(' Copyright '); var now = new Date(); document.write( + now.getFullYear()); document.write(' Jupitermedia Corporation All Rights Reserved.'); </script> <noscript> Copyright 2007 Jupitermedia Corporation All Rights Reserved.</noscript> <br> <a target="_blank" href="http://www.jupitermedia.com/corporate/legal.html" class="foot" target="_top">Legal Notices</a>, <a target="_blank" href="http://www.jupitermedia.com/corporate/reprints.html#Licensing1" class="foot" target="_top">Licensing</a>, <a target="_blank" href="http://www.jupitermedia.com/corporate/reprints.html#Reprints1" class="foot" target="_top">Reprints</a>, & <a target="_blank" href="http://www.jupitermedia.com/corporate/reprints.html#Permissions" class="foot" target="_top">Permissions</a>, <a target="_blank" href="http://www.jupitermedia.com/corporate/privacy/privacypolicy.html" class="foot" target="_top">Privacy Policy</a>. </font> <p> <font size="-2" face="verdana, arial, helvetica"><a target="_blank" href="http://www.jupitermedia.com/onlinemedia.html" class="foot" target="_top">Advertise</a> | <a target="_blank" href="http://e- newsletters.internet.com/" class="foot">Newsletters</a> | <a target="_blank" href="http://jobs.internet.com/" class="foot" target="_top">Tech Jobs</a> | <a target="_blank" href="http://www.internetshopper.com/" class="foot" target="_top">Shopping</a> | <a target="_blank" href="http://e- newsletters.internet.com/announcement_list.html" class="foot" target="_top">E- mail Offers</a></div></font> </td> </form> </tr> </table></center> </center> </body></html>