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

160
Views
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
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!