×

Index

JavaScript Tutorial

JavaScript Examples

CSS Tutorial

CSS Examples

Date getUTCSeconds() method with example in JavaScript

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

JavaScript Date getUTCSeconds() method

getUTCSeconds() method is a Date's class method and it is used to get seconds from the current time according to the UTC (Universal time coordinated).

Syntax

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

Sample Input/Output

Input:
var dt = new Date();
dt.getUTCSeconds();
    
Output:
36

JavaScript code to get the current UTC seconds using getUTCSeconds() method

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

<body>
<script>
	var dt = new Date(); //Date constructor 
	var Seconds1 = dt.getUTCSeconds(); //UTC Seconds 
	var Seconds2 = dt.getSeconds(); //local Seconds
	//printing Seconds
	document.write("UTC Seconds = " + Seconds1 + "<br>");
	document.write("Local Seconds = " + Seconds2 + "<br>");
</script>
</body>
</html>

Output

UTC Seconds = 37
Local Seconds = 37

Reference: JavaScript getUTCSeconds() Method

JavaScript Date Object Methods »




Comments and Discussions!

Load comments ↻





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