为什么ExtJS在格式化日期时减去一天? [英] Why does ExtJS subtract a day when formatting a date?
本文介绍了为什么ExtJS在格式化日期时减去一天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 ExtJS 4.0.2
,我可以在控制台中输入以下内容:
Ext.util.Format.date('2012-01-13',mdY);
我得到 01-12-2012
/ p>
为什么?
我可以用以下方式更正:
Ext.util.Format.date('2012-01-13 00:00:00',mdY);
解决方案
Ext 4.0中Ext.util.Format.date。 2使用Date对象或String(您的情况)。使用UTC时区使用本机Date.parse()解析此字符串。
尝试使用Ext.Date.parse显式解析它:
var dt = Ext.Date.parse(2012-01-13,Ymd);
Ext.util.Format.date(dt,m-d-Y);
Using ExtJS 4.0.2
, I can type the following into the console:
Ext.util.Format.date('2012-01-13', "m-d-Y");
I get 01-12-2012
Why?
I can correct it with:
Ext.util.Format.date('2012-01-13 00:00:00', "m-d-Y");
解决方案
Ext.util.Format.date in Ext 4.0.2 uses a Date object or a String (your case). This string is parsed using the native Date.parse() using the UTC time zone.
Try to explicitly parse it using Ext.Date.parse:
var dt = Ext.Date.parse("2012-01-13", "Y-m-d");
Ext.util.Format.date(dt, "m-d-Y");
这篇关于为什么ExtJS在格式化日期时减去一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文