05-19-2020 11:43
05-19-2020 11:43
Hi !
I need help with my clock. I dunno how to put AM/PM with the preference setting
//****Clock*****//
// Update the clock every seconds
clock.granularity = 'seconds'; // seconds, minutes, hours
// Get a handle on the <text> element
const clockLabelStart = document.getElementById("clockLabelStart");
// Update the <text> element every tick with the current time
clock.ontick = function(evt) {
clockLabelStart.text = ("0" + evt.date.getHours()).slice(-2) + ":" +
("0" + evt.date.getMinutes()).slice(-2) + ":" ;
// Update the clock every seconds
clock.granularity = 'seconds'; // seconds, minutes, hours
// Get a handle on the <text> element
const clockLabelEnd = document.getElementById("clockLabelEnd");
// Update the <text> element every tick with the current time
clock.ontick = function(evt) {
clockLabelEnd.text = ("0" + evt.date.getSeconds()).slice(-2) ;
};
thanks in advance
05-19-2020 11:59
05-19-2020 11:59
Generally I use the expression:
TDate.getHours() < 12 ? "am" : "pm"
Where tDate = new Date()