SQLServer datetime field doesn't translate properly as javascript date object

548
1
03-20-2012 11:12 AM
DennisAkins
New Contributor
I am reading a date value directly from a sqlserver table and trying to display the value as text in an info wondiw using javascript api.  I can read the table, get the numeric value stored in the table, format the date into a useful string, and display the result.  My problem id the date is always one day behind what it read from the table.  Code snippet are:

                    var info = feature.attributes.desc
.
.
.
                        + "<br />Report Date : " + formatDate(feature.attributes.reportDate);
                    var template = new esri.InfoTemplate("", info);


        function formatDate(value) {
            if (value != null) {
                var inputDate = new Date(value);
                return dojo.date.locale.format(inputDate, {
                    selector: 'date',
                    datePattern: 'MM/dd/yyyy'
                });
            }
            else {
                return "null";
            }
        }


Has anyone else experienced this problem?  How can I fix this issue?
0 Kudos
1 Reply
derekswingley1
Frequent Contributor
This might be applicable:  http://gis.stackexchange.com/a/20319/124

Here's some code that might address your issue:  http://jsfiddle.net/yEkjm/
0 Kudos