新日期(代码)返回工作值,请帮帮我
var cdt = new Date();
dob = "15/01/1999";//From date picker
alert(dob);
var bdy = dob.split("/");
var by = bdy[2];
var bm = bdy[0];
var bd = bdy[1];
var dob = new Date(bd, bm, by);
alert(bd+","+bm+","+by);
alert(dob);
新日期()函数的日期格式已更改:
该函数返回值:
答案 0 :(得分:1)
new Date()
方法在构造函数上有三个参数。
参数的顺序如下:year
,month
和day
。
像这样:var date=new Date(1999,01,01)
。
var cdt = new Date();
dob = "15/01/1999";//From date picker
var bdy = dob.split("/");
var by = bdy[2];
var bm = bdy[1];
var bd = bdy[0];
var dob = new Date(by, (bm-1), bd);
console.log(bd+","+bm+","+by);
console.log(dob.toLocaleDateString());