Calculate up from a particular year?

They have: 28 posts

Joined: Jan 2002

I'd like to automatically display the year of various film festivals on my movie site e.g. 55th Cannes Film Festival this year, 56th next year.

I've spent an hour looking for a javascript to calculate up from a particular year (1947 in the case of Cannes). There are various sites with scripts to calculate the number of days you have been alive etc., but not a single one for the number of years up from a particular year.

I found a script which calculates the number of days from a particular date (below). I was wondering if somebody could possibly convert it to count up from a year.

<script Language="JavaScript">
<!-- hide from old browsers
var today = new Date()
var targetDate = new Date("12/12/2001") //use full year
var timeAfterTarget = Math.floor(( today.getTime()
        - targetDate.getTime() ) / 86400000)
var msg = "Days up from specified date " + timeAfterTarget + "."
document.write(msg)
//-->
&lt;/script&gt;
'

One other thing: is it possible to incorporate this feature into the resultant year, so that it'll display the correct ending after the year, i.e. 51st, 52nd, 53rd.

Thank you VERY much. This will help me out big time Smiling

Nadeem Azam
1Lit.com Inc.

Free promotion - check out this 1:1 banner exchange
Dot com domains - the world's most prestigious domain names for sale

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

change 86400000 to 31557600000

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.