How to randomize time in momentJS?


This is my DateTime:

'2016-09-01 12:00:00'

how to randomize +/-15 mins before I save into MongodB

'2016-09-01 12:09:00'
'2016-09-01 12:15:00'
'2016-09-01 11:49:00'

I think the most straight forward would be to split it and randomise and then put back together, but I hope there would be a function that does it more elegantly:

2016-09-01 12: randomize: 00




Emm, why not to convert(or store) it as js object?
Anyway… Easiest aproach - use MomentJs

Math way - convert your time to Unix Time(integer), so 15 min is Math.random() * 1000 * 60 * 15 = 0-15 min
And so you can just substract or add it…

You may search StackOverflow answers for ready to use functions.

You can catch requests to db with Collection helpers for example. But I’d rather use Method.