Date Object Method In TypeScript: Part 4
Before reading this article, please go through the following articles:
Introduction
In this article, I am describing the date object's "getTime" and "getMinutes" method in the TypeScript.
getTime() Method
Syntax
- Date.getTime()
Function
- getTime() {
- var time = new Date();
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "getTime Method \n Display the number of milliseconds since midnight, January 1, 1970-> " + time.getTime() + "\n";
- document.body.appendChild(span);
- }
getMinutes() Method
In TypeScript, the getMinutes() method is used to get the minutes of the local time in the specified date or current date and time. The getMinutes method returns an integer value between 0 and 59.
Syntax
- Date.getminutes()
Function
- getMinutes() {
- var minutes = new Date();
- var span = document.createElement("span");
- span.innerText = "getMinutes Method \n The Minutes of the time right now-> " + minutes.getMinutes() + "\n";
- document.body.appendChild(span);
- }
Complete Program
getTime_getMinutes.ts
- class getTime_getMinutes {
- getTime() {
- var time = new Date();
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "getTime Method \n Display the number of milliseconds since midnight, January 1, 1970-> " + time.getTime() + "\n";
- document.body.appendChild(span);
- }
- getMinutes() {
- var minutes = new Date();
- var span = document.createElement("span");
- span.innerText = "getMinutes Method \n The Minutes of the time right now-> " + minutes.getMinutes() + "\n";
- document.body.appendChild(span);
- }
- }
- window.onload = () => {
- var obj = new getTime_getMinutes();
- obj.getMinutes();
- obj.getTime();
- };
getTime_getMinutes_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="getTime_getMinutes.js"></script>
- </head>
- <body>
- <h3>getTime and getMinutes method in TypeScript</h3>
- <div id="content"></div>
- </body>
- </html>
getTime_getMinutes.js
- var getTime_getMinutes = (function() {
- function getTime_getMinutes() {}
- getTime_getMinutes.prototype.getTime = function() {
- var time = new Date();
- var span = document.createElement("span");
- span.style.color = "Blue";
- span.innerText = "getTime Method \n Display the number of milliseconds since midnight, January 1, 1970-> " + time.getTime() + "\n";
- document.body.appendChild(span);
- };
- getTime_getMinutes.prototype.getMinutes = function() {
- var minutes = new Date();
- var span = document.createElement("span");
- span.innerText = "getMinutes Method \n The Minutes of the time right now-> " + minutes.getMinutes() + "\n";
- document.body.appendChild(span);
- };
- return getTime_getMinutes;
- })();
- window.onload = function() {
- var obj = new getTime_getMinutes();
- obj.getMinutes();
- obj.getTime();
- };
Output


Comments
Join the conversation! Your thoughts help the community grow.