Get UTC Hours, Minutes, Seconds, MilliSeconds javascript

Get UTC Hours, Minutes, Seconds, MilliSeconds javascript

javascript get utc hours, minutes, seconds and milliseconds. This tutorial explains to you how to get UTC time in hours, minutes, seconds and milliseconds in javascript.

In this tutorial we will take e.g. how to get the current time in milliseconds javascript, current time in seconds javascript, javascript date to hours, and javascript get utc minutes from date etc.

javaScript UTC Time

The you can use the following below methods for get utc time in hours, minutes, seconds and milliseconds JavaScript

  • getUTCHours()
  • getUTCMinutes()
  • getUTCSecond()
  • getUTCMilliSecond()

javaScript getUTCHours() Method

Definition:- Javascript getUTCHours() method which is used to get the hour for the specified date and time, according to universal time. The getUTCHours method will return an integer value between 0 to 23.

Syntax

 Date.getUTCHours();

Ex – javaScript getUTCHours() method

In this javascript getUTCHours method, we will take an example for getting hour from current date javascript.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript date.getUTCHours Method</title>
</head>
<body>
  <script type = "text/javascript">
     var currentDate = new Date();
     document.write("the javascript date.getUTCHours() : " + currentDate.getUTCHours() ); 
  </script>  
</body>
</html>

Result of the above code is:

JavaScript date.getUTCHours Method

JavaScript getUTCMinutes() Method

Definition:- Javascript getUTCMinutes() method which is used to get the minute for the specified date and time, according to universal time. The getUTCMinutes method will return an integer value between 0 to 59.

Syntax

date.getUTCMinutes();

Ex – javaScript getUTCMinutes() method

In this javascript getUTCMinutes method, we will take an example for getting minutes from current date javascript

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript date.getUTCMinutes Method</title>
</head>
<body>
  <script type = "text/javascript">
     var currentDate = new Date();
     document.write("the javascript date.getUTCMinutes() : " + currentDate.getUTCMinutes() ); 
  </script>  
</body>
</html>

Result of the above code is:

JavaScript date.getUTCMinutes Method

javaScript getUTCSeconds() Method

Definition:- Javascript getUTCSeconds() method, which is used to get the seconds for the specified date and time, according to universal time. The getUTCSeconds method will return an integer value between 0 to 59.

Syntax

date.getUTCSeconds();

Ex – javaScript getUTCSeconds() method

In this javascript getUTCseconds method, we will take an example for getting current time in seconds javascript

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript date.getUTCSeconds Method</title>
</head>
<body>
  <script type = "text/javascript">
     var currentDate = new Date();
     document.write("the javascript date.getUTCSeconds() : " + currentDate.getUTCSeconds() ); 
  </script>  
</body>
</html>

Result of the above code is:

JavaScript date.getUTCSeconds Method

JavaScript getUTCMilliseconds() Method

Definition:- Javascript getUTCMilliseconds() method, which is used to get the milliseconds for the specified date and time, according to universal time. The getUTCMilliseconds method will return an integer value between 0 to 59.

Syntax

 date.getUTCMilliseconds();

Ex – javaScript getUTCMilliseconds() method

In this javascript getUTCMilliseconds method, we will take an example for getting the current time in milliseconds javascript

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript date.getUTCMilliseconds Method</title>
</head>
<body>
  <script type = "text/javascript">
     var currentDate = new Date();
     document.write("the javascript date.getUTCMilliseconds() : " + currentDate.getUTCMilliseconds() ); 
  </script>  
</body>
</html>

Result of the above code is:

JavaScript date.getUTCMilliseconds Method

Note: If you want to pass custom date or time in date function you can use pass date or time like this:

new Date("July 21, 1983 01:15:00:195");

Conclusion

In this javascript get utc time tutorial, you have learned how to get utc time in hours, minutes, seconds and milliseconds javascript with example.

You may like

  1. JavaScript: Date.getUTCDate() Method
  2. javaScript: getUTCFullYear Method
  3. getUTCMonth Method in JavaScript
  4. javaScript: getUTCDay() Method By E.g.
  5. javaScript Digital Clock with date
  6. JavaScript: Set Date Methods
  7. String Contains JavaScript | String includes() Method
  8. JavaScript Get Date Methods
  9. JavaScript Operators With Examples
  10. Sorting Using JavaScript Array Sort() Method
  11. JavaScript Replace String With Examples
  12. JavaScript Array splice() Method By Example
  13. JavaScript: Clone an Array & Object By Example

If you have any questions or thoughts to share, use the comment form below to reach us.

AuthorTuts Make

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Javascript, JQuery, Laravel, Livewire, Codeigniter, Vue JS, Angular JS, React Js, WordPress, and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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