1
如何使用as2計算給定日期和今天之間的天數?使用as2計算特定日期的天數
如何使用as2計算給定日期和今天之間的天數?使用as2計算特定日期的天數
通過這個代碼
// 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");
http://stackoverflow.com/questions/7298635/comparing-two-date-values-in-actionscript-possible-to-compare-whole-day-values – paul