|
在获取当前时间存到数据库中,数据库的字段类型是DateTime,用如下代码获取当前的时间!格式化当前时间会报错,e.getFullYear() is not a function!
直接将获取到的clock存到数据库中报错信息为 请填写正确的日期时间!
var bbb =justep.Date.fromString(kkk, 'yyyy-MM-dd HH:mm:ss');
alert(bbb); 使用这段代码转换时间格式, kkk有当前时间的值,但是bbb=undefined;
本人使用的是WeX5,有明白的老师帮忙解答一下!谢谢!
Model.prototype.button2Click = function(event){
this.comp("complaintData").newData();
debugger;
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var ss = now.getSeconds(); //秒
var clock = year + "-";
if(month < 10)
clock += "0";
clock += month + "-";
if(day < 10)
clock += "0";
clock += day + " ";
if(hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10)
clock += '0';
clock += mm + ":";
if (ss < 10)
clock += '0';
clock += ss;
var kkk= clock;
var aaa = justep.Date.toString(kkk, 'yyyy-MM-dd HH:mm:ss');
var bbb = justep.Date.fromString(kkk, 'yyyy-MM-dd HH:mm:ss');
this.comp("complaintData").setValue("tfId","123");
this.comp("complaintData").setValue("tfTouSRXM","123");
this.comp("complaintData").setValue("tfXingM","123");
this.comp("complaintData").setValue("tfChuangJShJ",aaa);
this.comp("complaintData").saveData();
alert(clock);
};
|
|