Time in ArcMap vs Time Format in Javascript map

729
3
Jump to solution
08-17-2012 06:44 AM
BillShockley
Occasional Contributor
OK.....if I load the layer into Arcmap the time is

8/17/2012 9:35:13 AM

But if I run it through a javascript map using this function:

function formatDate(value){      var inputDate = new Date(value);      return dojo.date.locale.format(inputDate, {      selector: 'date',      datePattern: 'MMMM d, y, h:mm:ss '      });


I get the same date but its 7 hours ahead.
August 17, 2012, 4:35:13

Why??

Any help is much appreciated!
0 Kudos
1 Solution

Accepted Solutions
BillShockley
Occasional Contributor
OK.....if I load the layer into Arcmap the time is 

8/17/2012 9:35:13 AM 

But if I run it through a javascript map using this function: 

function formatDate(value){      var inputDate = new Date(value);      return dojo.date.locale.format(inputDate, {      selector: 'date',      datePattern: 'MMMM d, y, h:mm:ss '      });


I get the same date but its 7 hours ahead. 
August 17, 2012, 4:35:13 

Why?? 

Any help is much appreciated!


I got it.
Just add 18000000 to the value

function formatDate(value){      var inputDate = new Date(value+18000000);      return dojo.date.locale.format(inputDate, {      selector: 'date',      datePattern: 'MMMM d, y, h:mm:ss '      });

Sometimes you have to think simple in a Unix world.

View solution in original post

0 Kudos
3 Replies
ReneRubalcava
Frequent Contributor
I'm not horribly famiiar with with the dojo date library, but if you add 'a' to your format it will give am/pm or change 'h' to 'H' to get 24 hours time, because it looks like maybe it could be 5 hours behind or 7 hours ahead.

Looking at the dojo docs for the dojo.date.locale.format, you may need to adjust for timezone and timezone offset to get the correct result.
http://dojotoolkit.org/reference-guide/1.7/dojo/date/locale/format.html
0 Kudos
BillShockley
Occasional Contributor
I'm not horribly famiiar with with the dojo date library, but if you add 'a' to your format it will give am/pm or change 'h' to 'H' to get 24 hours time, because it looks like maybe it could be 5 hours behind or 7 hours ahead.

Looking at the dojo docs for the dojo.date.locale.format, you may need to adjust for timezone and timezone offset to get the correct result.
http://dojotoolkit.org/reference-guide/1.7/dojo/date/locale/format.html


Yes it is 5 hours behind...but how do I adjust it to read the Time-Zone I'm in?
0 Kudos
BillShockley
Occasional Contributor
OK.....if I load the layer into Arcmap the time is 

8/17/2012 9:35:13 AM 

But if I run it through a javascript map using this function: 

function formatDate(value){      var inputDate = new Date(value);      return dojo.date.locale.format(inputDate, {      selector: 'date',      datePattern: 'MMMM d, y, h:mm:ss '      });


I get the same date but its 7 hours ahead. 
August 17, 2012, 4:35:13 

Why?? 

Any help is much appreciated!


I got it.
Just add 18000000 to the value

function formatDate(value){      var inputDate = new Date(value+18000000);      return dojo.date.locale.format(inputDate, {      selector: 'date',      datePattern: 'MMMM d, y, h:mm:ss '      });

Sometimes you have to think simple in a Unix world.
0 Kudos