javascript - how to get time with some specific format? -


how should gettime specific format want time hh:mm am/pm , add minute . example have date 2016-09-16t11:40:50.000z first time 11:40 am , add 20 minutes , result 12:00 am so, how can task. try date.gettime() not give me proper time want.

function gettime(date) {  var hours = date.gethours();  var minutes = date.getminutes();  var ampm = hours >= 12 ? 'pm' : 'am';  hours = hours % 12;  hours = hours ? hours : 12; // hour '0' should '12'  minutes = minutes < 10 ? '0'+minutes : minutes;  return = hours + ':' + minutes + ' ' + ampm; 

}


Comments

Popular posts from this blog

c++ - CPP, 'X' button listener -

.net - Bulk insert via Dapper is slower than inserting rows one-by-one -

shared memory - gstreamer shmsrc and shmsink with h264 data -