[英]Moment.js - Exact time til moment
Let's say that i have a moment object that is 20 hours ahead of now, and i want to display how long from the current time i have to wait to reuse a command.假设我有一个比现在提前 20 小时的时刻对象,我想显示从当前时间起我必须等待多长时间才能重用命令。 .fromNow()
gives me a result of In a day
Which tells me absolutely nothing. .fromNow()
给了我一个结果In a day
这完全没有告诉我什么。 what is the simplest way to get something like In [x] hours, [y] Minutes
?获得类似In [x] hours, [y] Minutes
的最简单方法是什么?
message.channel.send(`You already claimed your reward.\nCheck back ${moment(nd).fromNow()}`) // "In a day"
Thanks again.再次感谢。
A common way of displaying time is handled by moment#fromNow.显示时间的一种常见方式是由 moment#fromNow 处理。 This is sometimes called time ago or relative time.这有时被称为时间前或相对时间。
moment([2007, 0, 29]).fromNow(); // 4 years ago
If you pass true, you can get the value without the suffix.如果传递true,则可以获取不带后缀的值。
moment([2007, 0, 29]).fromNow(); // 4 years ago
moment([2007, 0, 29]).fromNow(true); // 4 years
Try this尝试这个
var a = moment([2007, 0, 28]);
var b = moment([2007, 0, 29]);
a.from(b);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.