I understand this is a popular question on the internet. But the point is that I need to do something accurately and as I'm not very familiar with working with dates, I needed to ask this question.
My problem is the following, from a timestamp I have to define certain actions. These actions are taken under the following conditions:
Prep
- starts about an hour before timestamp;
Run
- starts right at timestamp;
Reset
- this action is taken if 15 minutes have passed after the timestamp;
Bearing in mind that the timestamp would be the following:
const timestamp = "2021-11-16T09:18:02 0000"
I had the idea to do it this way:
const time = moment(timestamp).diff(moment(), "minutes")
But to be honest I don't know how I can improve this. Can you help?