JS 时间格式为/Date(1332919782070)/ 转化为正常的格式
2018-01-19 16:26
381 查看
function ChangeDateFormat(val) { if (val != null) { var date = new Date(parseInt(val.replace("/Date(", "").replace(")/", ""), 10)); //月份为0-11,所以+1,月份小于10时补个0 var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); return date.getFullYear() + "-" + month + "-" + currentDate; } return ""; }
相关文章推荐
- JS 时间格式为/Date(1332919782070)/ 转化为正常的格式
- Js:消息弹出框、获取时间区间、时间格式、easyui datebox 自定义校验、表单数据转化json、控制两个日期不能只填一个
- js 将php生成的time()类型时间戳转化成具体date格式的日期
- JS 时间格式化 对Date的扩展,将 Date 转化为指定格式的String
- json返回数据库的时间格式为/Date(1332919782070)/,在前台用js怎么转换
- 四八、js封装格式化时间(将 Date 转化为指定格式的String)
- vue.js将时间戳转化为日期格式的实现代码
- 时间格式字符串转化为date和时间戳
- 用DateFormat处理时间格式,转化为timestamp形式存入数据库(以XXXX年XX月XX日为例)
- js---Date.parse()转化日期为时间戳,ios与Android兼容写法
- Java转换Json日期/Date(1487053489965+0800)/格式以及js时间格式 Tue Feb 14 2017 14:06:32 GMT+0800
- 利用JS实现时间格式转化
- js将后台传过来的时间戳转化成固定格式的字符串
- js扩展Date将时间格式化为"yyyy-MM-dd hh:mm:ss"格式的字符串
- js将时间戳转换成正常的yyyy-m-d格式
- 时间格式转换—将后台返回的/Date(1448954018000)/格式转换为正常的时间格式
- js 小技巧 (速将一个字符串或者时间戳转化成Date对象)
- ConvertJSONDateToJSDateObject 方法实现json格式时间串转换为 对应的时间格式串
- JS将字符串类型的时间格式转换为date格式
- JS DATE和时间戳之间相互转化