1

如何使用 as2 计算给定日期和今天之间的天数?

4

1 回答 1

2

浏览这段代码

// 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");
于 2012-09-04T14:07:15.263 回答