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