I get the date/time value as below in JSON:
"ChangedDate":"\/Date(1349469145000)\/"
In FF and IE, I get the above date in 12 hr format (10/5/2012 – 3:32:25 PM) using the helper function below:
Handlebars.registerHelper('FormatDate', function (date) {
if (date == null)
return "";
else {
var value = new Date(parseInt(date.substr(6)));
return value.getMonth() + 1 + "/" + value.getDate() + "/" + value.getFullYear() + " - " + value.toLocaleTimeString();
}
});
however, in Chrome I still get the 24 hr format (10/5/2012 – 15:32:25).
How do I get the date/time value in 12 hr format in Chrome?
You may be better off changing this line:
to:
Where we check to see if the hours are
> 12and if so we subtract 12 from that number.So your example
15:32:25would be15 - 12 = 3:3:32:25.https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getSeconds
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getMinutes
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/getHours
EDIT
I made this example a bit more detailed than needed, but it helps to show you what’s going on. Hope it helps.
EXAMPLE
Condensed down this would look something like:
EXAMPLE