Calculate with msg.date from email in node

Hi Forum, I try to calculate with the msg.date object from the email in node

  • node-red-node-email v1.12.3

msg.date = "2021-07-28T04:32:28.000Z"

Is there a way to querry just the emails recieved in the last X minutes? I hope I dont need to calculate the seconds until 1970 myself :smile:

You could try something like this in a function node:

let minutes = 50; // email can't be older than 50 minutes

let age = (new Date() - new Date(msg.date)) / (1000 * 60); // age in minutes

// only return if it's not too old
if(age < minutes){
    return msg;
}
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.