I need to be able to let clients schedule a certain type of meeting for a future date, the meeting duration I get back from the database is in minutes. I need to be able to create a future start date and time, then add the duration minutes to that time and get the end date and time. Then convert those two to utc time and iso format to send to backend. I know how to convert to utc and iso, just not sure of the best way to add times with the duration being in minutes. Any one know the best way to do this with javascripts date api, moment.js or another library?
CodePudding user response:
I like to approach problems with time using the date-fns library. Today the Date object solves "most" of our problems so date-fns helps giving useful functions to manipulate dates.
What you want might be looking for is the add minutes function. Also the formatISO might help.
For UTC, the UTC method should work fine.
CodePudding user response:
With the Date API, you can:
// hours
date.setHours(date.getHours() someHours);
// minutes
date.setMinutes(date.getMinutes() someMinutes);
// whatever else...