Bug
| Bug-ID-Nummer | NIM079740 |
|---|---|
| Eingereicht | April 6, 2012 |
| Zuletzt geändert | June 5, 2024 |
| Gilt für | ArcGIS API for JavaScript |
| Gefunden in Version | 10.0 |
| Programmsprache | JavaScript |
| Betriebssystem | Windows OS |
| Betriebssystemversion | 7 |
| Status | Will Not Be Addressed |
Change the code to reflect the correct time zone. Since the feature is a UTC timestamp, the JavaScript code is converting to the users' timezone, which (assuming in the US) is four to seven hours earlier than midnight of 8/15/2007, which is why it is returning one day earlier.
As per the forum link:
<a href="http://forums.arcgis.com/threads/53385-SQLServer-datetime-field-doesn-t-translate-properly-as-javascript-date-object?highlight=date" target="_blank">http://forums.arcgis.com/threads/53385-SQLServer-datetime-field-doesn-t-translate-properly-as-javascript-date-object?highlight=date</a>
Below is the method which we need to use
function CustomDate(featureTime) {
console.log("formatting function called", featureTime);
// get the timezone offset from UTC time
var tzoffset = new Date().getTimezoneOffset();
// add the time zone offset to the timestamp
var utctime = dojo.date.add(new Date(featureTime), "minute", tzoffset);
return dojo.date.locale.format(utctime, { "selector": "date" });
}
Bug-ID: NIM079740
Software:
Unterstützung durch ArcGIS-Experten anfordern
Esri Support App herunterladen