My goal is to prevent an email from being sent more than once in a 24 hour period. I have a schema:
var requestSchema = new mongoose.Schema({
email: String,
lastSent: Date
});
In my Express route I'm testing to see if the lastSent
variable is more than one day ago...
var lastSent = new Date(existingRequest.lastSent);
var nextDate = new Date() - 1;
if (lastSent > nextDate) {
if (constants.dev){ console.log('Signup request too soon'); }
} else {
// Process request
}
... however I cannot seem to catch the date. Logging the dates to the Express console shows this:
Last Sent: Tue Dec 16 2014 10:12:54 GMT-0500 (Eastern Standard Time)
Threshold: 1418746385786
Is there a chance that the date formats are mismatched?