I am following this ESRI tutorial to display information from a related table for the selected features. The example in itself for my project works fine, however, my data include two Date fields and when I display them on the right side grid, I see something like "1237507200000" as starting date and "1237161600000" as ending date.

I understand I have to format this esriFieldTypeDate so I can display it as a text field like "YYYY-MM-DD", but I don't know how. It is important to highlight that this related records are stored in a dojo.data.ItemFileReadStore as in the example.

Please, does anyone know how to do this?


1 Answer 1


"1237507200000" is a date in tics, just use a regular js-date object to convert to string. When you map the items object from feature.attributes object, you can do the conversion. For example something like this:

var items = dojo.map(fset.features, function(feature) {
            var dataAttr = new Date(  feature.attributes.date )
            feature.attributes.date = dataAttr.toLocaleString() ;
            return feature.attributes;

 var data = {
            identifier: "OBJECTID",  //This field needs to have unique values
            label: "OBJECTID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
            items: items

          //Create data store and bind to grid.
          store = new dojo.data.ItemFileReadStore({ data:data });
          grid.setQuery({ OBJECTID: '*' });
  • 3
    Rather than looping through all of the features I would use a formatter on the field. For a large dataset you are adding an uncesssary loop through the data. See Formatter on dojotoolkit.org/reference-guide/1.8/dojox/grid/DataGrid.html Commented Feb 13, 2013 at 12:55
  • Thanks, it simply works perfectly!! I changed the date modifier to "datePattern: 'MMMM d, y' " to match my criteria. :-)
    – Irene
    Commented Feb 14, 2013 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.