资源描述:
《日期时间脚本库方法列表》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1. 日期时间脚本库方法列表 2.Date.prototype.isLeapYear 判断闰年 3.Date.prototype.Format 日期格式化 4.Date.prototype.DateAdd 日期计算 5.Date.prototype.DateDiff 比较日期差 6.Date.prototype.toString 日期转字符串 7.Date.prototype.toArray 日期分割为数组 8.Date.prototype.DatePart 取日期的部分信息 9.Date.prototype.MaxDayOfDate 取
2、日期所在月的最大天数 10.Date.prototype.WeekNumOfYear 判断日期所在年的第几周 11.StringToDate 字符串转日期型 12.IsValidDate 验证日期有效性 13.CheckDateTime 完整日期时间检查 14.daysBetween 日期天数差 15. 16.js 代码 17. 18.//--------------------------------------------------- 19.// 判断闰年 20.//--------------------------
3、------------------------- 21.Date.prototype.isLeapYear = function() 22.{ 23.return (0==this.getYear()%4&&((this.getYear()%100!=0)
4、
5、(this.getYear()%400==0))); 24.} 25. 26.//--------------------------------------------------- 27.// 日期格式化 28.// 格式 YYYY/yyy
6、y/YY/yy 表示年份 29.// MM/M 月份 30.// W/w 星期 31.// dd/DD/d/D 日期 32.// hh/HH/h/H 时间 33.// mm/m 分钟 34.// ss/SS/s/S 秒 35.//--------------------------------------------------- 36.Date.prototype.Format = function(formatStr) 37.{ 38.var str = formatStr; 39.var
7、 Week = ['日','一','二','三','四','五','六']; 40. 41. str=str.replace(/yyyy
8、YYYY/,this.getFullYear()); 1. str=str.replace(/yy
9、YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100)); 2. 3. str=str.replace(/MM/,this.getMont
10、h()>9?this.getMonth().toString():'0' + this.getMonth()); 4. str=str.replace(/M/g,this.getMonth()); 5. 6. str=str.replace(/w
11、W/g,Week[this.getDay()]); 7. 8. str=str.replace(/dd
12、DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate());
13、9. str=str.replace(/d
14、D/g,this.getDate()); 10. 11. str=str.replace(/hh
15、HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours()); 12. str=str.replace(/h
16、H/g,this.getHours()); 13. str=str.replace(/mm/,this.getMinutes()>9?this.getMinute
17、s().toString():'0' + this.getMinutes());