Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

198
Visualizações
How to convert a time of any country to a specific timezone's time?

Let's suppose my time in India is 9:30AM, so i want to convert this time to some other timezone of a different country.

Click here to see the image preview for this.

So, i hve this timeslots of 45 mins each of Asia/Calcuuta, and as you see someone has booked the first 2 time slots.

So, now as i as another user from Asia/Karachi try to book the time slot, first it overrides and interchanges the Asia/Calcutta time to Asia/Karachi, but the issue is that those 2 booked slots are show here as Avialable. I want that anyone from any timezone see the booked slots as well.

Click here to see the image preview for this.

  for(var i=0;i<slotsArray.length;i++)
  {
    for(var j=0;j<this.bookedTimingsOfUser.length;j++)
    {
    var getStartValInSlice = (this.bookedTimingsOfUser[j][0].userstartTime).slice(0, -3);
 
    if((momenttm(date+ " " + slotsArray[i].timeSlotStart).tz(timezone)).tz(this.bookedTimingsOfUser[j][0].userBookedTimezone).format('LT')  == momenttm(date+ " " + getStartValInSlice).tz(this.bookedTimingsOfUser[j][0].userBookedTimezone).format('LT') &&  moment(getDate.value).format('LL')  == this.bookedTimingsOfUser[j][0].userbookedDate)     

      slotsArray[i].timeSlotStart = "Booked";
     
    }
  }
}

How can i achive this using JS or any other time conversion npm packages like moments.js ???

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can pass timezone property to toLocaleString method to convert this time to different timezone

const timezoneSelect = document.querySelector('#timezones'),
  displayZone = document.querySelector('strong');

timezoneSelect.addEventListener('change', function(e) {
  const date = new Date().toLocaleTimeString('en-US', {
    timeZone: this.value
  });
  displayZone.innerText = date;
})
<select name="timezones" id="timezones">
  <option value="Asia/Kolkata">Asia/Kolkata</option>
  <option value="Asia/Karachi">Asia/Karachi</option>
</select>

<p>Current Time: <strong>HH:MM:SS</strong></p>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda