Boyye
Boyye

Reputation: 291

Calculate days until specific date with as2

How can I calculate the days between a given date and today with as2?

Upvotes: 1

Views: 807

Answers (1)

Viral Shah
Viral Shah

Reputation: 2246

go through this code

// set up a date variable for Christmas 2006
// (n.b. Months are in the range 0-11)
var_Christmas = new Date(2006,11,25)
// set up a variable for todays date
var_Today = new Date();
// calculate the difference in milliseconds between the dates
difference_milliseconds = var_Christmas - var_Today;
trace (difference_milliseconds);
// convert millisecond difference into days
// (n.b. 1000 ms per second, 60000 ms per minute, 3600000 ms per hour, 86400000 ms per day)
difference_days = Math.floor(difference_milliseconds/86400000);
trace("There are " + difference_days + " days before Christmas");

Upvotes: 2

Related Questions