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 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 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 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:
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
- JavaScript: Date.getUTCDate() Method
- javaScript: getUTCFullYear Method
- getUTCMonth Method in JavaScript
- javaScript: getUTCDay() Method By E.g.
- javaScript Digital Clock with date
- JavaScript: Set Date Methods
- String Contains JavaScript | String includes() Method
- JavaScript Get Date Methods
- JavaScript Operators With Examples
- Sorting Using JavaScript Array Sort() Method
- JavaScript Replace String With Examples
- JavaScript Array splice() Method By Example
- JavaScript: Clone an Array & Object By Example
If you have any questions or thoughts to share, use the comment form below to reach us.