- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 MomentJS,目前 moment().toObject()
输出
{
years:2016,
months:10,
date:3,
hours:18,
milliseconds:85,
minutes:26,
seconds:26
}
如何将输出格式更改为
{
year: 2016, //without 's'
month: 10, //without 's'
day: 3, // instead of date
...
}
最佳答案
只需构建一个新对象:
var a = moment().toObject();
var b = { year: a.years, month: a.months + 1, day: a.date };
请注意,我增加了月份以考虑输出月份 0-11 而不是 1-12 的时刻。您可能想要也可能不想要,但认为在这里指出可能有用。
关于javascript - moment().toObject() 输出格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40407007/
我正在使用 MomentJS,目前 moment().toObject() 输出 { years:2016, months:10, date:3, hours:18, milliseconds:85,
在此answer ,并且用户已在此处向 toObject 方法添加了一些内容: PostModel changedModel = documentChange.getDocument().toObje
当toSource方法用于一个对象时..它会是这样的 ({name:"myname", value:"myvalue"}) 我的问题是如何将它转换回对象?或者更确切地说,只是访问像这样的属性 aler
这是我在 Firestore 中的 Class 数据模型: 这是我的 Kotlin 模型中的 Class。 data class Class( var teacher: String = ""
我有一些 JSon 的一部分,我试图将其映射到 C# 对象。 JSon 的其余部分正确映射到对象,但只有这部分不映射任何内容并且对象值为空。 这是我调用的代码 var data = JObject.P
我最近看到一个使用这种风格的项目: (SomeEnum)Enum.ToObject(typeof(SomeEnum), some int) 而不是这种风格: (SomeEnum)some int 为什
我有类似以下代码: User.findOne(id) .exec((err, user) => { Pets.find(_.pluck(user.pets, 'id'))
出于学习目的,我开始浏览 Node js-express 应用程序代码。遇到以下行,不确定以下行中 getter 和 virtual 的使用。 var pgmsDbObj = chnnlList[c
我想从 firebase firestore 获取数据并使用数据类转换 toObject()。但它不起作用,因为对象已初始化但未设置字段。 这与 Firebase Firestore toObject
所以我们使用的可能是相当旧的 Spring 属性转换风格。基本上,当页面加载时,它会将实体对象转换为其 id 值,然后当页面提交时,它会获取 id 值,通过该 id 查找实体对象并将其填充回来。 示例
当使用字符串属性在 JObject 上调用 ToObject 时,转换日期时间值。 class Program { static void Main(string[] args) {
我在 Android 项目中使用 Firestore。 我有一个 Transaction 模型,它有一个 org.threeten.bp.LocalDateTime 日期 字段。 当我尝试通过调用 d
我正在尝试学习 MongoDB/Node,但我注意到在架构中我经常看到这样的内容: toObject: { virtuals: true } toJSON: { virtuals: true } 这两
据我了解,没有 .toObect()在 JavaScript 中,但它在 mongoose 中用于将 mongoose 文档更改为对象,以便您可以使用 JavaScript 内置函数。 我不知道什么时
Mongoose documentation for toObject列出了功能、选项,并给出了 toObject 的功能示例。 toJSON 的 Mongoose 文档表示选项与 toObject
我想将文档快照转换为 pojo 对象。但我无法理解这个 .toObject() 方法背后的逻辑。有人可以解释一下它的工作原理,即参数、它是如何工作的、我应该如何在 firebase 中使用它。 pri
我在将 JSON 文本序列化为包含 SecureString 变量的对象时遇到问题。我如何序列化以下内容,同时将公共(public)“pwd”变量保留为 SecureString? 假设有以下字符串:
借助 Cloud Firestore,您可以使用 document.toObject(YourClass.class); 将文档转换为对象,其中类的变量与数据库中的变量匹配。但是,如果数据库中的一个变
我正在尝试从 JObject 创建 .NET 对象,但我将对象的所有属性设置为默认值(string 为 null,int 为 0 等) 我正在创建一个简单的 Jobject: var jsonObje
我在原始 Canvas 对象上设置了一些用户定义的属性,当我使用canvas.getActiveObject.toObject()时,结果无法显示用户定义的属性,我该怎么办可以让它显示出来吗?或者是我
我是一名优秀的程序员,十分优秀!