« 正己律人百箴参考 | 首页 | 正则表达式中的特殊字符 »

日期格式字符串转日期型数据

var strDate="2006-12-21";
var arys= new Array();
arys=strDate.split('-');
var startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);
注意:Date.getMonth的值范围为0~11(对应1月~12月)
Date.getDay的值范围为0~6(对应星期日~星期六)

发表评论

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.2