I'm trying to display Sofia Local Time for every user that enters my website so that it does not matter what's the time of the user or the server of my website deployed.
This is JS but it displays the user's time.How to display current time in Sofia/Bulgaria .I use asp.net for server side language
<script>
$(document).ready(function () {
var time = new Date().toLocaleString('en-US', { hour:'numeric', minute:'numeric' ,timeZone: 'Europe/Sofia' });
document.getElementById("Time").innerHTML = time;
setInterval(change, 60000);
function change() {
var x = (new Date().toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', timeZone: 'Europe/Sofia' }));
document.getElementById('Time').innerHTML = x;
}
});
</script>
You can convert to various time zones using toLocaleString . Or use moment.js. Check this post. Here is a fiidle http://jsfiddle.net/tva7o4jx/