Re: Date Calculation

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Laura Hast" <l4521hast@xxxxxxxxxxx> wrote in message
news:OWgFLyPMIHA.4688@xxxxxxxxxxxxxxxxxxxxxxx
I need to insert a javascript date calculation on a webpage. I need to
calc today's date minus a start_date to give me a count of the days

example

today - start_date = count_days

This script works for me, if it's what you need. Obviously you need to
change the "March 17, 2004" and the "St. Patrick's day" to whatever you want
it to be.

---------------------------------------------------

Put in body of page where statement needs to go.

<script language="JavaScript">
<!--
var now= new Date();
var stpats = new Date("March 17, 2004" );
var how_long= stpats.getTime() - now.getTime();
var days = Math.ceil(how_long/ (60*60*1000*24));
var from= (how_long<0)? "since":"until"
document.write("There are "+days+" days "+from+" St. Patrick's day.")
//-->
</script>

-----------------------------------------------------


--
Patty Ayers | www.WebDevBiz.com
Free Articles on the Business of Web Development
Web Design Contract, Estimate Request Form, Estimate Work***
--


.


Quantcast