简体   繁体   English

如何抵消moment.js时间Object

[英]How to offset moment.js time Object

I got created time from MongoDB and I want add 6 hours for that.我从 MongoDB 获得了创建时间,我想为此增加 6 小时。 I want a visible button if now time less than after add 6 hours for created time.如果现在时间少于创建时间添加 6 小时后,我想要一个可见的按钮。 I use moment.js我使用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您可以使用: moment(time).add(x, 'hours')其中time是您想要偏移 x 小时的时间 object

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM