- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用时刻来开始新的一天。我得到以下不同的结果:
moment().startOf('day'); //good
moment(new Date()).startOf('day'); //this does not work!
function doWork(dt) {
return moment(dt).startOf('day');
}
最佳答案
我建议使用 format()
显示矩对象的值。
如 Internal Properties指南指出:
Moment objects have several internal properties that are prefixed with
_
.The most commonly viewed internal property is the
_d
property that holds the JavaScript Date that Moment wrappers. Frequently, developers are confused by console output of the value of_d
....
To print out the value of a Moment, use
.format()
,.toString()
or.toISOString()
console.log(moment().startOf('day').format());
console.log(moment(new Date()).startOf('day').format());
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
关于momentjs startOf 不适用于现有的日期对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44811933/
我正在尝试使用时刻来开始新的一天。我得到以下不同的结果: moment().startOf('day'); //good moment(new Date()).startOf('day'); //th
我遇到了我认为是 moment.js 中的错误。想在这里发布以确认/否认。注意:我通过 Titanium Studio 运行它,但它仍然是 javascript。 执行以下操作: var today
我正在尝试使用 moment.js 获取一天(距今天几天)的开始和结束时间。这是我的代码: var today = moment(); var day = today.add(-5, "days");
我通过查询字符串传递以下日期:2020-09-23 我想弄清楚为什么上面带有不起作用注释的下面的代码不起作用。 // If figure here I should only have to conv
为了聚合一些东西,我需要在数据对象中设置月份。我正在尝试使用此代码获取每个月的开始时间 moment("2018-09-04T13:06:07.397Z").startOf('month').toDa
我已阅读 documentation of com.datastax.driver.core.utils.UUIDs.startOf ,但我仍然不明白两个略有不同的 UUID 是如何给出相同的时间戳的
在 joda-time 库中(我假设是 Java 8 的新时间库),你可以忽略时间和时区:https://www.joda.org/joda-time/apidocs/org/joda/time/Lo
我有一个日期存储在 YYYY-MM-DD 中。该日期用于创建一个名为 then 的时刻。我想计算该日期与现在(时刻)之间的天数。 计算天数时,我使用:now.startOf('day').from(t
我是一名优秀的程序员,十分优秀!