I have a created date. I want to run an if/switch statement to know whether the date and time right now is more than 24 hours from the created date.
If the created date is more than 24 hours ago, do something, if it's less than 24 hours ago do something else.
let now = +new Date();
// This is returned as: July 18, 2018 at 3:48:00 AM UTC+1
let createdAt = +doc.data().created_at;
const oneDay = 60 * 60 * 24;
var compareDatesBoolean = (now - createdAt) > oneDay;
Any guidance here would be great thank you! :)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…