JSFiddle - React, Tailwind, and code Playground

by Julien Vernet

HTML

The local time in Bangkok is
<time class="wpas-timeagent"></time>. <strong class="">The support is now closed.</strong><strong class="">The support is now open.</strong>

<br>
<br>
<div class="another-test"></div>
<div id="result"></div>

JavaScript

function calcTime(offset) {
    // create Date object for current location
    var d = new Date();

    // convert to msec
    // add local time zone offset
    // get UTC time in msec
    var utc = d.getTime() + (d.getTimezoneOffset() * 60000);

    // create new Date object for different city
    // using supplied offset
    var nd = new Date(utc + (3600000 * offset));

    // return time as a string
    // return nd.toLocaleString();
    return nd.getHours() + ':' + nd.getMinutes();
}

$('.wpas-timeagent').html(calcTime('+7'));

// Get today's date in local timezone
// var Today = new Date();
// var d = Today.getUTCDate();
// $('.another-test').html(d);

// $("#result").load("http://www.timeapi.org/+7/now?format=%20%25I:%25M:%25S%20");

var time = Date.now()
console.log(time);