how to use the minutestohours function from date-fns in javascript

To use minutestohours from date-fns library in Javascript, you need to first install the package using npm or yarn as shown below:

npm install date-fns --save
28 chars
2 lines

or

yarn add date-fns
18 chars
2 lines

Once the package is installed, you can import the minutestohours function and use it in the following way:

import { minutestoHours } from 'date-fns';

const minutes = 120; // some value in minutes
const hours = minutestoHours(minutes);

console.log(hours); // Output: 2
163 chars
7 lines

In the above example, we imported the minutestoHours function from date-fns and used it to convert 120 minutes to its equivalent 2 hours. The function takes the number of minutes as its argument and returns the value in hours.

gistlibby LogSnag