Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 as in the example.

Please, does anyone know how to do this?


share|improve this question
up vote 5 down vote accepted

"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 =, function(feature) {
            var dataAttr = new 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{ data:data });
          grid.setQuery({ OBJECTID: '*' });
share|improve this answer
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 – David Wilton Feb 13 '13 at 12:55
Thanks, it simply works perfectly!! I changed the date modifier to "datePattern: 'MMMM d, y' " to match my criteria. :-) – iamgin Feb 14 '13 at 11:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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