Possible Duplicate:
Formatting a date in JavaScript
How to get datetime in javascript?
I've found a script that displays the current date and time in various time zones. I can't figure out how to change the format. Currently, it displays as MM/DD/YYYY HH:MM:SS AM/PM
and I want it to just display as HH:MM AM/PM
I'm more skilled with jQuery than plain JavaScript, and this is confounding me:
$(document).ready(function() {
function calcTime(offset) {
currentDate = new Date();
utc = currentDate.getTime() + (currentDate.getTimezoneOffset() * 60000);
newDate = new Date(utc + (3600000*offset));
return newDate.toLocaleString();
}
function displayTimes() {
$("#chicago").html(calcTime("-6"));
$("#london").html(calcTime("+1"));
$("#shanghai").html(calcTime("+8"));
};
window.setInterval(displayTimes, 1000);
});