Date Object Method In TypeScript: Part 7
Before reading this article, please go through the following articles:
-
-
-
-
-
-
Introduction
The Date object is the key to date and time functionality in TypeScript. If we create it with no argument passed to its constructor, it will contain the date and time of the user's computer. The Date object also provides a number of functions dealing with something called Coordinated Universal Time (UTC), also known as Greenwich Mean Time (GMT) during winter. The World Time Standard is set by the UTC time.
In this article, I am describing the date object's "getUTCMinutes" and "getUTCSeconds" methods in the TypeScript.
getUTCMinutes() Method
In TypeScript, the getUTCMinutes method returns the minutes between 0 and 59 of the specified date and time or the current date, identical to universal time. The getUTCMinutes method() calculates their date assuming that the date object is of local time and date.
Syntax
Function
- getUTCMinutes() {
- var minute = new Date();
- var span = document.createElement("span");
- span.innerText = "getUTCMinutes Method \n Current Minutes, According to UTC-> " + minute.getUTCMinutes() + "\n";
- document.body.appendChild(span);
- }
getUTCSeconds() Method
The getUTCSeconds method() is used to get the second for specified date and time or current date, identically to UTC. The getUTCSeconds method() calculates their date assuming that the date object is of local time and date. The World Time Standard is the UTC time.
Syntax
Function
- getUTCSeconds() {
- var second = new Date();
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "getUTCSeconds Method \n Current Seconds, According to UTC-> " + second.getUTCSeconds() + "\n";
- document.body.appendChild(span);
- }
Complete Program
getUTCMinutes_getUTCSeconds.ts
- class getUTCMinutes_getUTCSeconds
- {
- getUTCMinutes()
- {
- var minute = new Date();
- var span = document.createElement("span");
- span.innerText = "getUTCMinutes Method \n Current Minutes, According to UTC-> " + minute.getUTCMinutes() + "\n";
- document.body.appendChild(span);
- }
- getUTCSeconds()
- {
- var second = new Date();
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "getUTCSeconds Method \n Current Seconds, According to UTC-> " + second.getUTCSeconds() + "\n";
- document.body.appendChild(span);
- }
- }
- window.onload = () =>
- {
- var obj = new getUTCMinutes_getUTCSeconds();
- obj.getUTCMinutes();
- obj.getUTCSeconds();
- };
getUTCMinutes_getUTCSeconds_MethodDemo.htm
- <!DOCTYPE html>
- <html lang="en"
- xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta charset="utf-8" />
- <title>TypeScript HTML App</title>
- <link rel="stylesheet" href="app.css" type="text/css" />
- <script src="getUTCMinutes_getUTCSeconds.js"></script>
- </head>
- <body>
- <h3>getUTCMinutes and getUTCSeconds method in TypeScript</h3>
- <div id="content"></div>
- </body>
- </html>
getUTCMinutes_getUTCSeconds.js
- var getUTCMinutes_getUTCSeconds = (function() {
- function getUTCMinutes_getUTCSeconds() {}
- getUTCMinutes_getUTCSeconds.prototype.getUTCMinutes = function() {
- var minute = new Date();
- var span = document.createElement("span");
- span.innerText = "getUTCMinutes Method \n Current Minutes, According to UTC-> " + minute.getUTCMinutes() + "\n";
- document.body.appendChild(span);
- };
- getUTCMinutes_getUTCSeconds.prototype.getUTCSeconds = function() {
- var second = new Date();
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "getUTCSeconds Method \n Current Seconds, According to UTC-> " + second.getUTCSeconds() + "\n";
- document.body.appendChild(span);
- };
- return getUTCMinutes_getUTCSeconds;
- })();
- window.onload = function() {
- var obj = new getUTCMinutes_getUTCSeconds();
- obj.getUTCMinutes();
- obj.getUTCSeconds();
- };
Output