[英]Create Date in Moment.js
I am not seeing it in the documentation but I am wondering if I can do something similar like in C# 我在文档中没有看到它,但是我想知道是否可以在C#中执行类似的操作
DateTime d = new DateTime(2019,01,01);
I would like to do that with moment 我想马上做
var d = moment(2019,01,01);
but that does not seem to work. 但这似乎不起作用。
I can see I could do something like 我可以看到我可以做类似的事情
var d = momment('2019-01-01');
but I want to do it separately so I can do something like 但我想单独做,所以我可以做类似的事情
Datetime d = new DateTime(now.Year + 1, 01, 01);
您可以使用Template Literal将变量注入到瞬时参数字符串中:
let date = moment(`${moment().year()}-01-01`).add(1, 'years');
You can use following constructor: 您可以使用以下构造函数:
var d = moment({ year: 2019, month: 1, day: 1});
Or: 要么:
var d = moment([2019, 1, 1]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.