Date field is wrong in pop up from Query result in app - but correct in Mxd.

5026
7
Jump to solution
12-29-2014 12:31 PM
AlicePence
Occasional Contributor II

When someone performs a query in my application - they get the wrong date showing in the popup; however the correct date is in the .mxd that has the service. When I did a query on the map service - I notice that both my date fields look a bit odd (and there are few other ones too highlighted in red) because its missing the double quotes when you look at the JSON result.

I checked multiple places to see if I had the layer ID's right and made sure everything is pointed to the correct service and they are, so I'm not sure if this is where I'm getting that error. For the example below the correct "Installed" date should be 10/1/1967 but in the query its returning 9/30/1967.

json.jpg.png

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Might have something to do with the time zone... If I enter "-71107200" (seconds, not milliseconds) in the epoch converter: Epoch Converter - Unix Timestamp Converter ... I get this result:

GMT: Sun, 01 Oct 1967 00:00:00 GMT

Your time zone: 30-9-1967 19:00:00 GMT-5:00

View solution in original post

7 Replies
XanderBakker
Esri Esteemed Contributor

Might have something to do with the time zone... If I enter "-71107200" (seconds, not milliseconds) in the epoch converter: Epoch Converter - Unix Timestamp Converter ... I get this result:

GMT: Sun, 01 Oct 1967 00:00:00 GMT

Your time zone: 30-9-1967 19:00:00 GMT-5:00

AlicePence
Occasional Contributor II

This is like the biggest 'holy crap - that makes so much sense' moment of the day. How would I go about changing the Time Zone issue? Or is that question for a different group?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Good question... you could post this question in the place corresponding the language of the app you developed. You can find a list of places here:Web Developers

0 Kudos
AlicePence
Occasional Contributor II

Thanks! This lead us in the correct direction!!

0 Kudos
DavidColey
Frequent Contributor

Hi Alice-

I should post this in the Javascript API Place but in the meantime here is a date convert function we put together for EST, where the constant value is the GMT offset for EST in seconds.

convertDate = function (jsDate){
      //console.log(jsDate);
  var myDate = locale.format(new Date(Math.abs(jsDate + 14400000)),{
       selector: "date",
       datePattern: 'MMMM d, yyyy'
  });
  //console.log(Math.abs(jsDate + 14400000));
  return myDate;
  };

You'll need 

"dojo/date/locale"

and

"dojo/number"

for JS, not sure what would be used in the other APIs.  I strugggled with this one for awhile so I hope this helps!

David

0 Kudos
AlicePence
Occasional Contributor II

I sure do love coding in JavaScript - but unfortunately this app is in Silverlight (wasn't my choice) but it's another hint on how to get that date to show up in the correct format.

0 Kudos
DavidColey
Frequent Contributor

Sure thing.  It ought to be pretty similar though.  Just have to modify the function properites and constructor options ...

0 Kudos