[英]Moment.js How to display time remaining in day (with timezone offset)
[英]How to offset moment.js time Object
我从 MongoDB 获得了创建时间,我想为此增加 6 小时。 如果现在时间少于创建时间添加 6 小时后,我想要一个可见的按钮。 我使用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>}
您可以使用: moment(time).add(x, 'hours')
其中time
是您想要偏移 x 小时的时间 object
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.