首页 > 代码库 > js转换数据库中DateTime字段类型
js转换数据库中DateTime字段类型
在程序中,从数据库中读取到的日期时间类型数据一般是这种格式:"/Date(1355109408000+0800)/"
要经过js函数处理变为格式:‘2012-12-10 11:05:21‘
用此js函数即可搞定:
function timeFormatter(value) {
var da = new Date(parseInt(value.replace("/Date(", "").replace(")/" , "").split( "+")[0]));
return da.getFullYear() + "-" + (da.getMonth() + 1) + "-" + da.getDate() + " " + da.getHours() + ":" + da.getMinutes() + ":" + da.getSeconds();
}
js转换数据库中DateTime字段类型
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。