0

How to Add function by time (mixing if condition true ) ?

I have date (time) method how to add Condition of time if hour == 7{ Run function voice(); } https://code.sololearn.com/WWKF1ldIYOsF/?ref=app

27th Apr 2019, 2:44 AM
Omar Khalil Bakhsh
Omar Khalil Bakhsh - avatar
1 ответ
0
@Kaimi okay can you add this in example for better understanding plz !? if it is 7 am : var audio = new Audio(); audio.src = "GoodMorning.mp3"; audio.play() --------------------------------------my code ----------------------- setInterval(displaygold,500); // to reload every half siconeds function displaygold () { var time = new Date(); // get time frome date methode var hrs = time.getHours(); // get hours from time var min = time.getMinutes(); // ...minutes ..... var sic = time.getSeconds(); // .... siconeds .... var dy = 'am'; // set var day for am & pm mark if (hrs > 10 ){hrs='0'+hrs} // add 0 in hours if (hrs > 12){dy ='pm';} if (hrs > 12) { // becous i want 12 hour clock not 24 hrs = hrs - 12 ; // set it 0 } if (hrs == 0){ // if it is 0 set it 12 to restart hrs = 12; } document.getElementById('clock').innerHTML= hrs + ':' + min + ':' + sic + ' ' + dy ; };
27th Apr 2019, 11:01 PM
Omar Khalil Bakhsh
Omar Khalil Bakhsh - avatar