Code snippet to get the current datetime of other country
const d = new Date(); const localTime = d.getTime(); const localOffset = d.getTimezoneOffset() * 60000; const utc = localTime + localOffset; const offset = 4; // UTC of Dubai is +04.00 const dubai = utc + (3600000 * offset); const dubaiTimeNow = new Date(dubai).toLocaleString(); // Output: 08/22/2022, 11:07:27 AM
I hope you find this article helpful.
Thank you for reading. Happy Coding..!!