pvitt
pvitt

Reputation: 1065

Time stamp date time zone issue in dojo

I'm returning a timestamp from SQL server as an integer (seconds after 1/1/1970). The problem I'm having is that dojo (or javascript) is assuming the timestamp is GMT and then converting it to my local time zone. Is there a way to set the time zone when I create the new date, or tell dojo not to make the conversion? This is my code

 function formatDate(value) {
          // SQL Server returns seconds -- multiply by 1000 to get milliseconds 
          var date = new Date(parseInt(value) * 1000);
          return ddl.format(date, {//ddl is dojo/date/local
              selector: "date",
              datePattern: 'MM/dd/yyyy h:m a'
          });
      }

Because of standard and daylight times I really dont want to add time to my timestamp

Thanks

Upvotes: 0

Views: 1415

Answers (1)

pvitt
pvitt

Reputation: 1065

I found the answer here:

How do you create a JavaScript Date object with a set timezone without using a string representation

 var d = new Date(xiYear, xiMonth, xiDate);
 d.setTime( d.getTime() + d.getTimezoneOffset()*60*1000 );

Upvotes: 1

Related Questions