日期:2014-05-20 浏览次数:20818 次
String.prototype.isDate = function() { var p; var re1 = /(\d{4})[年./-](\d{1,2})[月./-](\d{1,2})[日]?$/; var re2 = /(\d{1,2})[月./-](\d{1,2})[日./-](\d{2})[年]?$/; var re3 = /(\d{1,2})[月./-](\d{1,2})[日./-](\d{4})[年]?$/; if(re1.test(this)) { p = re1.exec(this); return new Date(p[1],p[2],p[3]); } if(re2.test(this)) { p = re2.exec(this); return new Date(p[3],p[1],p[2]); } if(re3.test(this)) { p = re3.exec(this); return new Date(p[3],p[1],p[2]); } return null; } var d = "2008-01-01".isDate(); alert(d); alert("10-10-2009".isDate()); alert("13101-2009".isDate());
------解决方案--------------------
(另外如何支持 调用如何作
是否可以 var mydate=d(date_1) 还是 date mydate=d(date_1) ??
)
var mydate=d(date_1) 即可。
------解决方案--------------------
var date1_day=date_1.chinese wholesalers
ugg(0,2);
var date1_mon=date_1.substring(3,5);
var date1_year=date_1.substring(6,10);
------解决方案--------------------
between : function(date, start, end){
date = chinese wholesalers
uggparse(date); start = this.parse(start); end = this.parse(end);
if (date && start && end) {
var t = date.getTime();
return start.getTime() <= t && t <= end.getTime();