/**
* GetYearDayIndexByDate
* Get the Day in the year
*
* param: year [in] : the year , EX. 2010
* param: month [in] : the month , EX. 1
* param: date [in] : the date , EX. 1
*
* return: the index number of day
*
*
*/
function GetYearDayIndexByDate(year, month, date){
var dateArr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var _Index = 0;
// alert("_day : "+_day);
// alert("_month : "+_month);
// alert("_year : "+_year);
month = month -1 ; //getMonth()是从0開始
for (var i = 0; i < month; i++) {
_Index += dateArr[i];
}
_Index += date;
//判斷是否閏年
if (month > 1 && (year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
_Index += 1;
}
//alert("index : "+_Index);
return _Index;
}
以上轉貼修改自 http://wenwen.soso.com/z/q236092533.htm
沒有留言:
張貼留言