java日期格式 与json日期格式

您所在的位置:网站首页 日期的格式化调用________方法 java日期格式 与json日期格式

java日期格式 与json日期格式

2023-02-19 23:09| 来源: 网络整理| 查看: 265

格式化json日期格式对象: 调用:toDate(timeString); Date.prototype.format = function(format) { var o = { "M+" : this.getMonth() + 1, "d+" : this.getDate(), "h+" : this.getHours(), "m+" : this.getMinutes(), "s+" : this.getSeconds(), "q+" : Math.floor((this.getMonth() + 3) / 3), "S" : this.getMilliseconds() } if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + "")。substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp("(" + k + ")")。test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k])。substr(("" + o[k])。length)); } } return format; } // {"date":"3","day":"2","hours":"0","minutes":"0","month":"0","seconds":"0","time":"1325520000000","timezoneOffset":"- 480","year":"112"} function toDate(obj){ var date = new Date(); date.setTime(obj.time); date.setHours(obj.hours); date.setMinutes(obj.minutes); date.setSeconds(obj.seconds); return date.format("yyyy-MM-dd hh:mm:ss"); }



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3