PhasedEvolution PhasedEvolution - 1 month ago 5
Javascript Question

How to determine the date of an "X minutes from now" event

I have a function that gives me a number, represents minutes. I will use minutes to trigger an up-coming event. I want to know when the event is going to be triggered. I would like to get the exact date of the trigger in a way similar to this:

  • 2016-09-06 15:47:38 (years-months-days) (hours-minutes-seconds)

I wasn't able to find a thread that relates to this exact type of getting-future-data (minutes). Can someone help me with getting this done? Would be really grateful.


You can use momentjs and its add method:

var minutes = 28332832;
console.log(moment().add(minutes, 'minutes').format("YYYY-MM-DD HH:mm:ss"));
<script src=""></script>