Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
Making an Azan (alarm clock) to open an mp3 file when specific time in api and the device matches

I am building an Azan clock with Javascript with the following code, but the code does not launch the mp3 file when the time from the API and my PC match.

I am already converting the system time to string time to match with the API but it is kind of ignored by the console.

Screenshot of time format in console

both the system and API time matches

My code is below

// Enable JQuery
var script = document.createElement("script");

script.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js";

document.head.appendChild(script);

// Call and Parse the API
var request = new XMLHttpRequest();
request.open(
  "GET",
  "https://api.aladhan.com/v1/timingsByCity?city=AbuDhabi&country=uae&method=8",
  false
); // `false` makes the request synchronous
request.send(null);
if (request.status === 200) {
  var azan = JSON.parse(request.responseText);
}

// Convert system time format

var convertFormat = new Date().toLocaleTimeString("en-US", {
  hour: "numeric",
  hour12: false,
  minute: "numeric",
});

// Play the mp3 file if it is time
var intervalId = window.setInterval(function () {
  playazan();
  console.log("Checking Prayer Time");
}, 5000);

function playazan() {
  if (azan.data.timings.Asr === convertFormat) {
    new Audio('https://www.islamcan.com/audio/adhan/azan20.mp3').play()
    console.log("Its time for Dhuhrr");
  } else {
    console.log("Still time remains");
  }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!