function formatDate(value){ var inputDate = new Date(value); return dojo.date.locale.format(inputDate, { selector: 'date', datePattern: 'MMMM d, y, h:mm:ss ' });
Solved! Go to Solution.
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!
function formatDate(value){ var inputDate = new Date(value+18000000); return dojo.date.locale.format(inputDate, { selector: 'date', datePattern: 'MMMM d, y, h:mm:ss ' });
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
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!
function formatDate(value){ var inputDate = new Date(value+18000000); return dojo.date.locale.format(inputDate, { selector: 'date', datePattern: 'MMMM d, y, h:mm:ss ' });