在不知道确切的时间戳/天的情况下找到日期差异
我发现自己有点复杂。我需要找到两天的时间戳在毫秒内的时间戳,而不会预先定义任何一个。我所知道的是,我需要一个小的时间戳才能成为现在,我想我可以使用date.now()
(如果我错了,请更正我)。其他时间戳可以是一周中的任何一天,我无法控制用户选择的地方。
所以我想要这样的事情:
var dif = The future thursday - now
我只知道言语的日子。我不知道如何将其更改为毫秒的时间戳。
I have found my self in a bit of complication. I need to find the difference between two days timestamps' in milliseconds without predefining any of them. All I know is that I need the small timestamp to be now which I guess I can get by using Date.now()
(correct me if I'm wrong). The other timestamp can be any day of the week and I have no control over which the user picks.
So I want something like this:
var dif = The future thursday - now
I only know the days in words. I do not know how to then change that to timestamp in milliseconds.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过算术从一周的另一天开始获得一周中特定一天的下一个实例。然后,您可以在特定日期开始时获得该日期和午夜之间的区别,例如
You can get the next instance of a particular day of the week from another day of the week by arithmetic. You can then get the difference between that date and midnight at the start of a specific day, e.g.