您好,我想将此时钟设置为在Am和Pm之间切换,即中午12点至凌晨12点。
setInterval(function(){ time();}, 1000)
function time(){
var dates = new Date();
var newDates = dates.toDateString();
// var clock = dates.toLocaleTimeString();
var seconds = dates.getSeconds();
var minutes = dates.getMinutes();
var hours = dates.getHours();
var stringSeconds= String(seconds);
var stringMinutes= String(minutes);
var stringHours= String(hours);
newDate.textContent = newDates;
newDivSeconds.textContent = stringSeconds;
newDivMinutes.textContent = stringMinutes + ' :' ;
newDivHours.textContent = stringHours + ' :';