Get time-date from another City or Country in Javascript.

In this blog, I will teach you how to get another city or country time using Javascript.

You want to show a particular City or Country time in your project so you can easily get the time using Javascript.

So, Let’s start our tutorial:


Create a time.html file

Create a time.html file and put the below code.

<!DOCTYPE html>
	<title>Get time from another City or Country in jQuery -</title>
	<h1>Get time from another City or Country in jQuery.</h1>
	<p>Please <b>press F12 button</b> to open inspect of your browser.</p>
	<p>After open the inspect of your browser go to console and check the Output.</p>
	function findTime(city, offset) {
		d = new Date();
		utc = d.getTime() + (d.getTimezoneOffset() * 60000);
		convert = new Date(utc + (3600000*offset));
		return "The UTC time in " + city + " is " + convert.toLocaleString();
	alert(findTime('Mumbai', '+5.5'));
	alert(findTime('Singapore', '+8'));
	alert(findTime('Tokyo', '+9'));
	alert(findTime('London', '+1'));

Now, Open your browser and put the below code:


Happy Coding!

About Dhaval Shah

My name is Dhaval Shah. I'm a Laravel developer. I live in India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Java-script, JQuery, Laravel, WordPress, and Bootstrap.
Follow me on Github / Linkedin


Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!