By use moment js, When I want to add One hour to current time, I only want to increase the hour and Not the minutes? So the time 03:25 will be 04:00 and not 04:25 (which is wrong)
// below increase 60 minutes while I only need to round to the nearest hour
$('#eventTime').val(moment().add(1, 'hours').format('HH:mm'));
Hope the solution will work also when round to nearest month (get to first day of next month) or year and so on ...
Using startOf
method:
moment().startOf('hour').add(1, 'hours').format('HH:mm')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With