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

161
Visualizações
Updating date variable in JS

i have a discord bot with a timezones command and it's currently run off of VSCode on my computer. Unfortunately, the timezones command only works with the time when of when i start the bot, not when i call the command. I've attempted to wrap the "const/var now = new Date();" in a function, both standard and arrow functions but that makes anything that requires the date to do math (converting the time) undefined and returns an error as the variables are now not defined b/c they are wrapped in a function. The functions are commented out so it at least sort of works. here's my current code:

//function getTime() {
//const getTime = () => {
var now = new Date();
var timeHours;
var timeMinutes;
timeHours = now.getUTCHours();
timeMinutes = now.getUTCMinutes();  
var day = now.getDay();
var dayOfMonth = now.getDate();
var month = now.getMonth();
var ET = timeHours - 4;
var uzbek = timeHours + 5;
var meridiemET = " AM";
var meridiemUZ = " AM";
var ETm = timeHours - 4;
var year = now.getFullYear();
//}
//getTime();
//timezone math

if(ET>12) {
  ET=ET-12; 
  meridiemET = " PM";
}
if(ET<0) {
  ET=ET+12; 
  meridiemET = " PM";
}
about 4 years ago · Juan Pablo Isaza
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