Quote

Convert local date to any time zone in javascript

	function calcTimeZone(city, offset) {
	    var date = new Date();
	    var utc = date.getTime() + (date.getTimezoneOffset() * 60000);
	    var newDate = new Date(utc + (3600000 * offset));
	    return "Time in " + city + " is " + newDate.toLocaleString();
	}
	
	// Need to pass time zone offset
	console.log(calcTimeZone('Bombay', '+5.5'));
	console.log(calcTimeZone('California', '-8'));

Give a try jsFiddle

Advertisements

One thought on “Convert local date to any time zone in javascript

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s