Ext.util.Format.date
- var d = new Date(value.time);
- var s = Ext.util.Format.date(d, 'Y-m-d H:m:s');
- return s;
value.time: 1396257528000
d: Mon Mar 31 2014 17:18:48 GMT+0800 (中国标准时间)
s: "2014-03-31 17:03:48"
年月日时分秒中,只有分钟不对,硬生生的差了15分钟,汗!
单步跟踪进去,发现是Extjs的源码(VM13060)里有问题,竟然用月份代替了分钟:
- (function() {
- var Ext = window.ExtBox1;
- return Ext.String.leftPad(this.getFullYear(), 4, '0') + '-' + Ext.String.leftPad(this.getMonth() + 1, 2, '0') + '-'
- + Ext.String.leftPad(this.getDate(), 2, '0') + ' ' + Ext.String.leftPad(this.getHours(), 2, '0') + ':'
- + Ext.String.leftPad(this.getMonth() + 1, 2, '0') + ':' + Ext.String.leftPad(this.getSeconds(), 2, '0')
- })
- Ext.util.Format.date(d, 'Y-m-d H:i:s');
- formatCodes : {
- d: "Ext.String.leftPad(this.getDate(), 2, '0')",
- D: "Ext.Date.getShortDayName(this.getDay())",
- j: "this.getDate()",
- l: "Ext.Date.dayNames[this.getDay()]",
- N: "(this.getDay() ? this.getDay() : 7)",
- S: "Ext.Date.getSuffix(this)",
- w: "this.getDay()",
- z: "Ext.Date.getDayOfYear(this)",
- W: "Ext.String.leftPad(Ext.Date.getWeekOfYear(this), 2, '0')",
- F: "Ext.Date.monthNames[this.getMonth()]",
- m: "Ext.String.leftPad(this.getMonth() + 1, 2, '0')",
- M: "Ext.Date.getShortMonthName(this.getMonth())",
- n: "(this.getMonth() + 1)",
- t: "Ext.Date.getDaysInMonth(this)",
- L: "(Ext.Date.isLeapYear(this) ? 1 : 0)",
- o: "(this.getFullYear() + (Ext.Date.getWeekOfYear(this) == 1 && this.getMonth() > 0 ? +1 : "
- "(Ext.Date.getWeekOfYear(this) >= 52 && this.getMonth() < 11 ? -1 : 0)))",
- Y: "Ext.String.leftPad(this.getFullYear(), 4, '0')",
- y: "('' + this.getFullYear()).substring(2, 4)",
- a: "(this.getHours() < 12 ? 'am' : 'pm')",
- A: "(this.getHours() < 12 ? 'AM' : 'PM')",
- g: "((this.getHours() % 12) ? this.getHours() % 12 : 12)",
- G: "this.getHours()",
- h: "Ext.String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')",
- H: "Ext.String.leftPad(this.getHours(), 2, '0')",
- i: "Ext.String.leftPad(this.getMinutes(), 2, '0')",
- s: "Ext.String.leftPad(this.getSeconds(), 2, '0')",
- u: "Ext.String.leftPad(this.getMilliseconds(), 3, '0')",
- O: "Ext.Date.getGMTOffset(this)",
- P: "Ext.Date.getGMTOffset(this, true)",
- T: "Ext.Date.getTimezone(this)",
- Z: "(this.getTimezoneOffset() * -60)",
- c: function() {
- for (var c = "Y-m-dTH:i:sP", code = [], i = 0, l = c.length; i < l; ++i) {
- var e = c.charAt(i);
- code.push(e == "T" ? "'T'" : utilDate.getFormatCode(e));
- }
- return code.join(" + ");
- },
- U: "Math.round(this.getTime() / 1000)"
- },
原文链接:https://blog.csdn.net/gaojinshan/article/details/22683777