Specific time conversion from one timezone to multiple others

Asked Oct 14, 2026·2 replies·Last activity 18 days ago·Open in Discord ↗
This topic is closed
Still stuck? Ask the community on Discord.

Hello, is there a way to make a command that takes an hour number from one timezone and converts it to others? For example: !time 7 am would take 7 am from CEST timezone and convert it to to X UTC; Y PT; Z JST etc.
Thank you!

2 replies

you can do this with the $(eval) variable. Add this as the response for a !time command:

$(eval q=`$(query)`;m=q.toLowerCase().match(/(\d+):?(\d*) *(am|pm)?/);if(!m)'Usage: !time 7 am';else{h=+m[1];if(m[3])h=h%12+(m[3]=='pm'?12:0);n=new Date;s=z=>new Date(n.toLocaleString('en',{timeZone:z}));t=Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate(),h,+m[2])-(s('Europe/Paris')-s('UTC'));f=z=>new Date(t).toLocaleTimeString('en',{timeZone:z,hour:'numeric',minute:'2-digit'});`${q} CEST = ${f('UTC')} UTC; ${f('America/Los_Angeles')} PT; ${f('Asia/Tokyo')} JST`})

Example:

!time 7 am returns 7 am CEST = 5:00 AM UTC; 10:00 PM PT; 2:00 PM JST

Thank you very much, appreciate the help!