javascript根据日期判断星期几

来源:互联网 发布:知乎android客户端 编辑:程序博客网 时间:2024/05/29 19:28
<SCRIPT>   
var   s   =  '2011-11-17';   
alert( "今天星期 "+"天一二三四五六 ".charAt(new   Date(s).getDay()));   
alert("星期 "   +   new   Date(s).getDay());  
</SCRIPT>  
!————————————————————————————————————————
 
 
刚发现在IE中不能实现~解决办法如下:
 
 
<SCRIPT>   
var   s   =  '2011-11-17';   
//alert(new Date());  
//alert( "今天星期 "+"天一二三四五六 ".charAt(new  Date(s).getDay()));   
//alert(new Date().getDay());  
var b = new Date(Date.parse(s.replace(/\-/g,"/")));  
alert(b.getDay());  
</SCRIPT>  
现在都能实现