/    Sign up×
Community /Pin to ProfileBookmark

The JavaScript Source: Time and Date: Days Old

First: It does not work. Can you help me.

Below the whole code I used.

Second: I would like to have the result in YEARS. Like “”I am 65 years old”.

<HTML><HEAD><TITLE>How many days old are you</TITLE>
</HEAD>
<BODY><CENTER>
<BR><BR>
<TABLE BORDER=”1″ WIDTH=”95%” CELLSPACING=”0″ CELLPADDING=”0″>
<TR><TD><FONT CLASS=”titulo7v”>
<CENTER>SCRIPT para cálculo do tempo em dias entre uma data e datal atual<CENTER>

<SCRIPT LANGUAGE=”JavaScript”>

<!– How long have you had that job? How many days old are you?
Find the answers to these questions and more!

This script and many more are available free online at –>

<!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>

<!– Begin
var montharray=new Array(“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”);
function countup(yr,m,d) {
var today=new Date();
var todayy=today.getYear();

// Y2K Fix by Isaac Powell
// [url]http://onyx.idbsu.edu/~ipowell[/url]

if ((navigator.appName == “Microsoft Internet Explorer”) && (todayy < 2000))
todayy=”19″ + todayy;
if (navigator.appName == “Netscape”)
todayy=1900 + todayy;
var todaym=today.getMonth();
var todayd=today.getDate();
var todaystring=montharray[todaym]+” “+todayd+”, “+todayy;
var paststring=montharray[m-1]+” “+d+”, “+yr;
var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1);

document.write(“JSS was created ” + difference + ” days ago.”);
}

countup(1997,08,29); // Date in format: (year,month,day)
// End –>
</script>

<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>

<!– Script Size: 0.99 KB –>

</TD></TR></TABLE>

</BODY>
</HTML>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 07.2006 — [code=html]
<script type="text/javascript">
<!--//
function BirthDate(usrDate) {
var curDate = new Date();
curDate = new Date(curDate.getFullYear(), curDate.getMonth(), curDate.getDate());
var begDate = new Date(usrDate);
var difYear = curDate.getFullYear() - begDate.getFullYear();
if (curDate.getMonth() < begDate.getMonth()
|| (curDate.getMonth() == begDate.getMonth()
&& curDate.getDate() < begDate.getDate()) )
difYear = difYear - 1;
return difYear;
}
document.writeln("<p>The USA is ", BirthDate("07/04/1776"), " years old.</p>");
//-->
</script>
[/code]
×

Success!

Help @Guitel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...