一样的帖子??<SCRIPT LANGUAGE="JavaScript">
String.prototype.toDate = function(style){
var y = this.substring(style.indexOf('y'),style.lastIndexOf('y')+1);//年
var m = this.substring(style.indexOf('M'),style.lastIndexOf('M')+1);//月
var d = this.substring(style.indexOf('d'),style.lastIndexOf('d')+1);//日
if(isNaN(y)) y = new Date().getFullYear();
if(isNaN(m)) m = new Date().getMonth();
if(isNaN(d)) d = new Date().getDate();
alert(m)
var dt ;
eval ("dt = new Date('"+ y+"', '"+(m-1)+"','"+ d +"')");
return dt;
} alert("20081009".toDate("yyyyMMdd"))
alert("200829".toDate("yyyyMd"))
</SCRIPT>String.prototype.toDate = function(style){}
其实是类似于function toDate(style){}
只不过这个toDate函数只能作用于string类型变量
String.prototype.toDate = function(style){
var y = this.substring(style.indexOf('y'),style.lastIndexOf('y')+1);//年
var m = this.substring(style.indexOf('M'),style.lastIndexOf('M')+1);//月
var d = this.substring(style.indexOf('d'),style.lastIndexOf('d')+1);//日
if(isNaN(y)) y = new Date().getFullYear();
if(isNaN(m)) m = new Date().getMonth();
if(isNaN(d)) d = new Date().getDate();
alert(m)
var dt ;
eval ("dt = new Date('"+ y+"', '"+(m-1)+"','"+ d +"')");
return dt;
} alert("20081009".toDate("yyyyMMdd"))
alert("200829".toDate("yyyyMd"))
</SCRIPT>String.prototype.toDate = function(style){}
其实是类似于function toDate(style){}
只不过这个toDate函数只能作用于string类型变量
解决方案 »
- 这段效果里边为什么 将英文标题改写成中文 前台会显示不出来?
- JS弹出层在Chrome下会被视频播放器遮盖住
- JS confirm()对话框,如何让光标默认位置在取消按钮上?
- document.all是什么意思啊?
- Javascript中,Events对象是属于JS内置对象还是HTML DOM的对象?
- 有关 htc 的问题,PROPERTY 已经PUBLIC,却无法访问
- 一个javascript显示图片
- confirm问题,急
- 这个样式表是什么意思?
- radio非要放在form里才行吗
- javascript 中function(style)定义问题
- document.body.innerHTML 的相关问题
我看是的,O(∩_∩)O哈哈~