Conceal the passage of time with masks over the

I utilized the Datediff function to calculate the time difference in minutes.

The challenge I am facing is not being able to format the result in the hh:mm format.

Currently, it appears as 0:3, where the value obtained is 3 minutes, but I aim for 00:03.

SOLUTION

 var sec_num = self.Minutes  //self minutes = 3 minutes;
var hours = Math.floor(sec_num / 60);
var minutes = Math.floor(sec_num - hours * 60);
self.display = hours + ":" + minutes ;
return self.display;

IMPLEMENTATION

<span>{{display}}</span>

View Demo

Answer №2

To achieve the desired formatting, you can utilize moment js like so:

console.log(moment({"minutes": 3}).format('HH:mm'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Mastering the art of managing unchecked and checked checkboxes in Angular 2: A comprehensive guide

I have a code snippet where I want to display the initial state of checkboxes based on the 'initialstatus' array in the UI. I should be able to randomly change the status of any checkbox on the UI, and that change should also be reflected in the ...

How can I retrieve the index of an object within an array stored in Firestore?

I am currently working with Ionic and Firebase Firestore. My goal is to implement a functionality where users can click on a specific ion-card containing an object, triggering a method to display an ion-action-sheet with a Delete button. This would allow t ...

Single Component Tabs in Angular - Simplify your tab implementation with just one

As a newcomer to angular, I am trying to create tabs. I came across an intriguing example, but I am struggling to incorporate everything into the same component without using the tab component template. Is there a way to transfer all the content from the ...

How to resolve useState problem in useEffect when state is not null

Encountering issues with maintaining state in TypeScript React. A Child component passes a 'terminal' object to the Parent via a function called returnTerminal(). This 'terminal' object is then stored as a useState variable named _obje ...

How can I retrieve the chosen values from various checkboxes when I click a button?

<td><p><input class="checkbox" type="checkbox" value="Cars.id"> </p> </td> This is a list of car IDs with checkboxes for selection. <button (click)="duplicate()"><ion-icon name="color-wand"></ion-icon> & ...

Encountering a 404 error when trying to access the "assets" folder after deployment on App Service

After properly packaging my "assets" folder in the build, I encountered 404 errors when deploying on the App Service. Below is the angular.json configuration that includes everything in the folder: "assets": [ "src/assets&quo ...

Creating conditional statements in Angular 2 templates - the power of if, elseif

Can the if elseif else structure be used in an Angular 2 template? Here is an example of using if else: [text]="company ? company.name : 'Select a company'" I am looking to incorporate elseif into this. ...

The issue of excessive CPU usage is caused by the material-dropdown-select feature when combined with

Here is the html code I am working with: <material-dropdown-select [buttonText]="organizer?.name" [options]="filteredSailingClubs" [itemRenderer]="displayNameRenderer"> <div header> <material-select-searchbox ...

Navigating through a large array list that contains both arrays and objects in Typescript:

I have an array containing arrays of objects, each with at least 10 properties. My goal is to extract and store only the ids of these objects in the same order. Here is the code I have written for this task: Here is the structure of my data: organisationC ...

Proper management of setTimeout in an Angular application

I am working on a one-page web application where the main component's ngOnInit() function triggers a recursive function called loopDoSomething() using setTimeout: ngOnInit(): void { // Perform some operations this.loopDoSomething(); } loopDoSome ...

Challenge with Angular date selection component

I am currently utilizing ngbdatepicker in my form. I want to save the date separately and retrieve it as shown below. <input class="form-control ngbfield custom-form-control" required [ngClass]="{'is-invalid':f.touched && birthDay.inv ...

The function's return value encompasses various types, and the property does not exist within them

Currently, I am utilizing typescript for developing a NodeJS application. Within this application, I have incorporated a node module known as ts-md5, which contains a function called hashStr() that may return either a string or an Int32Array value. There ...

Creating or accessing maps using TypeScript and Cloud Functions in Firebase

In my document, there is a map referred to as "map" with a specific structure: -document -map {id: number} {id2: number2} When the function first executes, only the document exists and I need to create the map with an initial entry. Before ...

Curious about the missing dependencies in React Hook useEffect?

I'm encountering the following issue: Line 25:7: React Hook useEffect has missing dependencies: 'getSingleProductData', 'isProductOnSale', and 'productData'. Either include them or remove the dependency array react-hoo ...

Import all constants that have been exported in ES6 TypeScript and store them as an array

I am faced with the challenge of exporting multiple constants that I will later need to import and iterate through as an array. Due to my use of generics (OptionInterface) and the necessity to maintain type validations, I cannot simply place all constants ...

What is the process of transforming a jQuery element into a TypeScript instance?

In TypeScript, I am working with an object called DataTable that contains multiple methods, one of which is 'refresh' To display this DataTable on the page, it is structured as follows <table class='DataTable'>...</table> ...

Retrieve the :id parameter from the URL as a numerical value in Node.js using Typescript

Is there a way to directly get the :id param from the URL as a number instead of a string in order to easily pass it on to TypeORM for fetching data based on a specific ID? Currently, I am using the following approach where I have to create an additional ...

Using Generic Types in TypeScript Files for React Components

I have encountered an issue that I haven't been able to find a solution for online. When I define a function in a ts file like this: const lastGeneric = <T>(arr: Array<T>): T => { return arr[arr.length - 1]; } But when I try to do ...

Guide on assigning a class to an array of JSON objects in TypeScript

If I have an array of JSON objects, how can I cast or assign the Report class to it? console.log('jsonBody ' + jsonBody); // Output: jsonBody [object Object],[object Object] console.log('jsonBody ' + JSON.stringify(jsonBody)); // Outpu ...

The contenteditable DIV function is experiencing issues with Angular's two-way binding feature in the Firefox browser

After making my div contenteditable and triggering ngx-popover on keyup to display search results based on searchText, I am in need of two-way binding along with content editability. However, I prefer using a div instead of an input element: <span> ...