View Full Version : Display date/time as GMT, not browser default

3 May 2011, 5:56 PM
I have a gridpanel that has a date/time column in it. I really want to display the date/time as GMT date/time not the browsers default time.

I have put together a quick example, no matter what I try the time still gets displayed as the default timezone for my browser.

Ext.get(document.body).update('<div id="test"></div>');

var date = new Date('1998-04-15T20:24:31.2468Z');

var data = [{
id: 1,
date: date

var grid = new Ext.grid.GridPanel({
width: 600,
height: 300,
title: 'Testing Date',
renderTo: 'test',
store: new Ext.data.JsonStore({
fields: ['id', 'date'],
data: data
colModel: new Ext.grid.ColumnModel({
columns: [
{header: 'Id', width: 200, dataIndex: 'id'},
header: 'Last Updated', width: 135, dataIndex: 'date',
xtype: 'datecolumn', format: 'Y-m-d H:i:s O T'
viewConfig: {
forceFit: true

Since I am in the mountain time zone the date displayed is:
1998-4-15 14:24:31 -0600 MDT

But I would really like the time to display as:
1998-4-15 20:24:31 GMT

3 May 2011, 11:59 PM
I'm not sure you can do this with the Date.format function by default.
You could define a custom renderer or add your own date format pattern and use the date.getUTC* functions :