简体   繁体   中英

ExtJS Display Date/Time from server in ISO 8601 format

I have the following situation, I am display some files from Amazon S3 in an ExtJs grid. The information displayed includes, the Name, the Size, and Last Modified date time. Now the 'LastModified' displays the time in GMT in ISO 8601 format. I am wondering if there is any way for ExtJS to change that time when displaying to the time zone that the given computer is in?

Use the Ext.Date.format function to customize the format of a string representation of a JavaScript Date .

For example, the 'c' format seems to do what you're looking for:

Ext.Date.format(new Date(), 'c');

Returns:

2012-11-30T10:21:16-06:00

In a grid you can use the datecolumn xtype to render the date as you need it. here is an example:

 text:'Created Date',
 dataIndex:'dateCreated',
 xtype:'datecolumn', 
 format:'Y-m-d',
 width:80

Date format syntax is spelled out here . For the Timezone attribute 'T' the docs say:

T Timezone abbreviation of the machine running the code

I interpret this as saying the Timezone will be automatically set using the user's locale.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM