Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda