Ext.util.Format.date与Ext.Date.format区别, 转换时间戳


Ext.util.Format.date与Ext.Date.format区别, 转换时间戳

在Extjs中装时间戳使用如下两种都可以: 
Ext.util.Format.date(time,'U'); 
Ext.Date.format(time, 'U'); 
为了找到它们的区别,查看源代码,以Extjs 4.2 为例 
Ext.util.Format.date -> \src\util\Format.js 258

date: function(v, format) { if (!v) { return ""; } if (!Ext.isDate(v)) { v = new Date(Date.parse(v)); } return Ext.Date.dateFormat(v, format || Ext.Date.defaultFormat); },

Ext.Date.dateFormat -> \src\lang\Date.js 1186行

dateFormat: function(date, format) { return utilDate.format(date, format); },

Ext.Date.format -> \src\lang\Date.js 1211行

format: function(date, format) { var formatFunctions = utilDate.formatFunctions; if (!Ext.isDate(date)) { return ''; } if (formatFunctions[format] == null) { utilDate.createFormat(format); } return formatFunctions[format].call(date) + ''; },

结论: 
Ext.util.Format.date 封装了 Ext.Date.dateFormat 封装了 Ext.Date.format 
所以直接使用 Ext.Date.format 的效率最高


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM