JSFiddle - React, Tailwind, and code Playground
HTML
<div id="clockbox"></div>
<div id="clock"></div>
<div id="bombay"></div>
<div id="singapore"></div>
JavaScript
tday =new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
tmonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
function GetClock(){
d = new Date();
nday = d.getDay();
nmonth = d.getMonth();
ndate = d.getDate();
nyear = d.getYear();
if(nyear<1000) nyear=nyear+1900;
document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+"";
document.getElementById('clock').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+"";
setTimeout("GetClock()", 1000);
}
window.onload=GetClock;
function calcTime(city, offset) {
// create Date object for current location
d = new Date();
// convert to msec
// add local time zone offset
// get UTC time in msec
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
// create new Date object for different city
// using supplied offset
nd = new Date(utc + (3600000*offset));
// return time as a string
return "The local time in " + city + " is " + nd.toLocaleString();
}
document.getElementById('bombay').innerHTML=calcTime('Bombay', '+5.5');
document.getElementById('singapore').innerHTML=calcTime('Singapore', '+8');