Why does ExtJS subtract the day when formatting the date?

Using ExtJS 4.0.2 , I can enter the following into the console:

 Ext.util.Format.date('2012-01-13', "mdY"); 

I get 01-12-2012

Why?
I can fix this with:

 Ext.util.Format.date('2012-01-13 00:00:00', "mdY"); 
+4
source share
3 answers

Ext.util.Format.date in Ext 4.0.2 uses a Date or String object (your case). This string is parsed using the built-in Date.parse () using the UTC time zone.

Try to parse it explicitly using Ext.Date.parse:

 var dt = Ext.Date.parse("2012-01-13", "Ymd"); Ext.util.Format.date(dt, "mdY"); 
+2
source

This problem exists in Ext3, but the solution is slightly different:

 var dt = '2012-01-31'; //date string dt = Date.parseDate(dt, "Ymd"); Ext.util.Format.date(dt, 'm/d/Y'); //returns 01/31/2012 
0
source

If you cannot use Gregor’s answer (for example, by filling in the grid), note that changing the input to a date format other than ISO 8601 will also allow you to deploy the UTC partition. for instance

 Ext.util.Format.date('01/13/2012', "Ymd"); 

will give 2012-01-13

0
source

Source: https://habr.com/ru/post/1393233/


All Articles