View Full Version : Date values are always off by one day

16 Feb 2012, 12:59 PM

Total noob here with Sencha stuff, but I have an application using ExtJS3 and for some reason my date values are always displayed as the previous day.

So July 1, 2011 in the database would be displayed as June 30, 2011 on the app. I've tried explicitly entering in a static date value to display and the result is the same.

This seems to be purely a date display issue and does not affect how dates are stored to the database.

Can anyone offer me any insight on how I can resolve this? Thanks!

16 Feb 2012, 1:16 PM
I'm doing this and it works fine for me

new Date().format('Y-m-d')

16 Feb 2012, 2:08 PM
Hi Mitchell,

Thanks for the response. Unfortunately the problem still persists and it's still 1 day behind :((:((

23 Feb 2012, 7:30 AM
I'm having the same problem...what am I doing wrong?

This is my JSON data source:


This is my rendering code:

Ext.require([ 'Ext.grid.*',

Ext.onReady(function() {

// setup the state provider, all state information will be saved to a cookie

// create the data model
Ext.define('Group', {
extend: 'Ext.data.Model',
fields: [
{name: 'date', type: 'date'},
{name: 'group_name', type: 'string'},
{name: 'total_group', type: 'float'},

// create the data store

var store = Ext.create('Ext.data.Store', {
model: 'Group',
proxy: {
type: 'ajax',
url : '/select6.php',
reader: {
type: 'json',
root: 'dailyGroupTotals'
autoLoad: true

// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
stateId: 'stateGrid',
columns: [
text : 'Date',
width : 100,
sortable : true,
//renderer : Ext.util.Format.dateRenderer('m-d'),
dataIndex: 'date'
text : 'Group',
width : 100,
sortable : true,
dataIndex: 'group_name'
text : 'Total',
width : 150,
sortable : true,
renderer : 'usMoney',
align: 'right',
dataIndex: 'total_group'
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true

This is the resulting grid:


23 Feb 2012, 11:40 AM
You're probably seeing the GMT offset being applied to your dates, subtracting a few hours based on where you live. I think you might get around it by converting the date values to UTC, just a guess. Something like

..., {
name: 'myDate',
convert: function (v) {
return new Date(v+" UTC");

on your jsonreader might illuminate if that's the problem or not.

23 Feb 2012, 12:55 PM
Ext.define('Group', { extend: 'Ext.data.Model',
fields: [
{name: 'date', type: 'date', dateFormat: 'Y-m-d'},
{name: 'group_name', type: 'string'},
{name: 'total_group', type: 'float'},

Thanks Wes! Your suggestion put me on the right track. All that was needed was the addition of the dateFormat attribute in my model config.

Troy Wolf
2 Dec 2014, 10:39 AM
I'm late to the table, but I was having this exact issue with ExtJs 4.2 and confirmed I have the same issue with 3.4. The problem was that in my grid's model, I had this:

{name:"begin_dt", type:"string"}

When I should have had this:

{name:"begin_dt", type:"date", dateFormat: 'Y-m-d'}

That fixed the problem. In addition, I added this to the date columns in my columns list:

renderer: Ext.util.Format.dateRenderer('Y-m-d')

I Googled to figure this out. This page led me to the answer. Credit is due:


2 Dec 2014, 12:47 PM
For a grid column, you may want to check out the date column which makes it a bit more user friendly: http://docs.sencha.com/ext/5.0/apidocs/#!/api/Ext.grid.column.Date

7 Jun 2018, 4:08 AM
Currently facing with exact same issue; defined `dateFormat: 'Y-m-d' and dateWriteFormat: 'Y-m-d' on Modelbut nothing changes on CRUD payload. It's 2018-06-05T21:00:00.000Z//But should be 2018-06-06T06:05:00.000Z