×

Index

JavaScript Tutorial

JavaScript Examples

CSS Tutorial

CSS Examples

Date getTimezoneOffset() method with example in JavaScript

JavaScript Date getTimezoneOffset() method: Here, we are going to learn about the getTimezoneOffset() method of Date class with Example in JavaScript.
Submitted by IncludeHelp, on March 08, 2019

JavaScript Date getTimezoneOffset() method

getTimezoneOffset() method is a Date's class method and it is used to get the timezone difference between UTC and local time.

Syntax

var dt = new Date();
dt.getTimezoneOffset();

Sample Input/Output

Input:
var dt = new Date();
dt.getTimezoneOffset();
    
Output:
-330

JavaScript code to get the time difference between UTC and local time using getTimezoneOffset() method

<html>
<head><title>JavaScipt Example</title></head>

<body>
<script>
	var dt = new Date(); //Date constructor 
	var diff = dt.getTimezoneOffset();
	//printing timezone diff.
	document.write("Timezone diff. = " + diff + "<br>");
</script>
</body>
</html>

Output

Timezone diff. = -330

Reference: JavaScript getTimezoneOffset() Method

JavaScript Date Object Methods »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.