Date Object Method In TypeScript: Part 7

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
  1. Date.getUTCMinutes()  
Function
  1. getUTCMinutes() {  
  2.  var minute = new Date();  
  3.  var span = document.createElement("span");  
  4.  span.innerText = "getUTCMinutes Method \n Current Minutes, According to UTC-> " + minute.getUTCMinutes() + "\n";  
  5.  document.body.appendChild(span);  
  6. }  

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
  1. Date.getUTCSeconds()  
Function
  1. getUTCSeconds() {  
  2.  var second = new Date();  
  3.  var span = document.createElement("span");  
  4.  span.style.color = "Blue";  
  5.  span.innerText = "getUTCSeconds Method \n Current Seconds, According to UTC-> " + second.getUTCSeconds() + "\n";  
  6.  document.body.appendChild(span);  
  7. }  

Complete Program

 
getUTCMinutes_getUTCSeconds.ts
  1. class getUTCMinutes_getUTCSeconds  
  2. {  
  3.  getUTCMinutes()  
  4.  {  
  5.   var minute = new Date();  
  6.   var span = document.createElement("span");  
  7.   span.innerText = "getUTCMinutes Method \n Current Minutes, According to UTC-> " + minute.getUTCMinutes() + "\n";  
  8.   document.body.appendChild(span);  
  9.  }  
  10.  getUTCSeconds()  
  11.  {  
  12.   var second = new Date();  
  13.   var span = document.createElement("span");  
  14.   span.style.color = "Blue";  
  15.   span.innerText = "getUTCSeconds Method \n Current Seconds, According to UTC-> " + second.getUTCSeconds() + "\n";  
  16.   document.body.appendChild(span);  
  17.  }  
  18. }  
  19. window.onload = () =>  
  20.  { 
  21.   var obj = new getUTCMinutes_getUTCSeconds();  
  22.   obj.getUTCMinutes();  
  23.   obj.getUTCSeconds();  
  24.  };  
getUTCMinutes_getUTCSeconds_MethodDemo.htm
  1. <!DOCTYPE html>  
  2. <html lang="en"  
  3.     xmlns="http://www.w3.org/1999/xhtml">  
  4.     <head>  
  5.         <meta charset="utf-8" />  
  6.         <title>TypeScript HTML App</title>  
  7.         <link rel="stylesheet" href="app.css" type="text/css" />  
  8.         <script src="getUTCMinutes_getUTCSeconds.js"></script>  
  9.     </head>  
  10.     <body>  
  11.         <h3>getUTCMinutes and getUTCSeconds method in TypeScript</h3>  
  12.         <div id="content"></div>  
  13.     </body>  
  14. </html>  
getUTCMinutes_getUTCSeconds.js
  1. var getUTCMinutes_getUTCSeconds = (function() {  
  2.  function getUTCMinutes_getUTCSeconds() {}  
  3.  getUTCMinutes_getUTCSeconds.prototype.getUTCMinutes = function() {  
  4.   var minute = new Date();  
  5.   var span = document.createElement("span");  
  6.   span.innerText = "getUTCMinutes Method \n Current Minutes, According to UTC-> " + minute.getUTCMinutes() + "\n";  
  7.   document.body.appendChild(span);  
  8.  };  
  9.  getUTCMinutes_getUTCSeconds.prototype.getUTCSeconds = function() {  
  10.   var second = new Date();  
  11.   var span = document.createElement("span");  
  12.   span.style.color = "Blue";  
  13.   span.innerText = "getUTCSeconds Method \n Current Seconds, According to UTC-> " + second.getUTCSeconds() + "\n";  
  14.   document.body.appendChild(span);  
  15.  };  
  16.  return getUTCMinutes_getUTCSeconds;  
  17. })();  
  18. window.onload = function() {  
  19.  var obj = new getUTCMinutes_getUTCSeconds();  
  20.  obj.getUTCMinutes();  
  21.  obj.getUTCSeconds();  
  22. };  
Output
 
result.jpg