Can anyone please help me get the HH:MM am/pm format instead of HH:MM:SS am/pm.
My javascript code is :
You may also try like this:-
function timeformat(date) {
var h = date.getHours();
var m = date.getMinutes();
var x = h >= 12 ? 'pm' : 'am';
h = h % 12;
h = h ? h : 12;
m = m < 10 ? '0'+m: m;
var mytime= h + ':' + m + ' ' + x;
return mytime;
}
or something like this:-
new Date('16/10/2013 20:57:34').toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, "$1$3")