I'm setting up a system that needs to have posts that expire, and I need to compare the two to determine if it's expired. I'm using Meteor so I can do this on the clientside or serverside (i'm assuming the latter is preferred).
Looking into the MDN, i'm not quite sure how to store the timestamps and what format to use. It seems like the most naive way would be to use Date.now()
for the current time and add 30 days in ms for the expired timestamp. Is there a better way to do this?
postModel = {
id: String
createdOn: Date.now()
expiresOn: Date.now() + 2592000000 // 30days
}
post = getPost()
if (post.expires is after now) {
// throw expired error
}