Reputation: 139
I got created time from MongoDB and I want add 6 hours for that. I want a visible button if now time less than after add 6 hours for created time. I use moment.js
timenow:moment().format('LT')
{this.state.timenow > moment(post.createdAt).format('LT') &&
<Button
variant="outline-info"
className="cardbutton"
size="sm"
onClick={this.editPost.bind(this, post._id, post.message)}
>
Edit
</Button>}
Upvotes: 2
Views: 130
Reputation: 1571
You can use:
moment(time).add(x, 'hours')
where time
is the time object you want to offset by x hours
Upvotes: 2