0

I am wanting to create an alarm clock system that creates multiple alarms based off the first one.

So, if the user put in "10:00" I want to display that in an array, then +6 hours (new time 16:00) and push that to an array, then another 4 hours (20:00) and push that to an array.

The issue is, I am using an input type "time" and, with that it is not as simple as "plus 60" or whatever. I am wondering what the correct way to do this would be?

Maybe there is a simple way to "add time" to a time type, or if there is another way around it then convert it back to time later?

Here is my input form snippet -

<form @submit.prevent="Calculate">
   <input type="time" class="timepicker" name="timepicker" min="00:00" max="23:59" v-model="time" required>
   <button>Submit</button>
</form>

As for the methods, they are currently just console.log as I cannot figure it out.

Thanks!

KJParker
  • 710
  • 2
  • 9
  • 26
  • 1
    Possible duplicate of [Add 2 times together JavaScript](https://stackoverflow.com/questions/25764553/add-2-times-together-javascript) – ryeMoss Jan 04 '19 at 13:50
  • @ryeMoss that does somewhat help but then my question is, in their example they use "var theFutureTime = moment().hour('12').minute('44').add(4,'hours').format("HH:mm");" But, how would i pass in the hour and minute separately into this, when i have received it as a single piece of data? (how do i split hours and minutes to pass them into this argument) – KJParker Jan 04 '19 at 15:39
  • I would look at the second answer in the example. It does not use the momentjs library and has helper functions that splits up the data and does the calculations – ryeMoss Jan 04 '19 at 16:14

0 Answers0