简体   繁体   English

在jQuery中将年,月和日转换为单个日期

[英]Convert year, month and day to single date in jQuery

The ruby method 红宝石法

DateTime.new(@year, @month, @day) DateTime.new(@year,@month,@day)

uses three integers @year @month and @day to create a single datetime. 使用三个整数@year @month@day创建单个日期时间。

Is there a jQuery method that accomplishes this? 是否有实现此目标的jQuery方法?

No there isn't a jQuery method for this but you can do it with pure JS. 没有这个的jQuery方法,但是您可以使用纯JS来实现。

var date = new Date(2015, 9, 28);

Note: For this particular example months are 0-based, so the 9 in the example above means October. 注意:对于此特定示例,月份是从0开始的,因此上面示例中的9表示十月。

Read more about it here: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date 在此处了解更多信息: https : //developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM