Converts a number of minutes into a user-friendly string, e.g. 80 minutes becomes '1 hour & 20 minutes'.
npm install minutes-to-string --save
Import and reference the minutesToString function like so:
const minutesToString = require('minutes-to-string');
const timeString = minutesToString(80); // returns '1 hour & 20 minutes'
When calling the minutesToString function, you can pass it two arguments to alter its behavior. The first argument is the number of minutes you want converted to a string. The second argument is a separator between the hours and minutes string that is returned.
Details of each argument are below:
minutes (number) (required)
Default value: none
The number of minutes you want converted to a string.
separator (string) (optional)
Default value: ' &'
The string that separates the number of hours and minutes listed. Examples could include:
- ' and' would return '1 hour and 20 minutes'
- ',' would return '1 hour, 20 minutes'