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>}
You can use: moment(time).add(x, 'hours')
where time
is the time object you want to offset by x hours
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.