I have the following function using moment which checks the difference in minutes from a given UNIX timestamp. actualStartTime is in unix format (for e.g 1599226113699)
const endTime = moment(offer.data.actualStartTime, "x")
if (endTime.diff(now, "minutes") <= 15 && snapshot.key) {
remindersSentKeys.push(snapshot.key)
}
Unix timestamp is stored in offer.data.actualStartTime
. My problem is I need to add another field duration: number
which adds hours in the endTime
variable and return in the moment format.
const finalEndTime = moment(offer.data.actualStartTime, "x") + *offer.data.duration*
For e.g if duration is 4
. The variable finalEndTime
should add an additional 4 hours in the actualStartTime
and then check the 15 min difference.