我正在尝试使用 Java 版本:
Date d = new Date(2010, Calendar.AUGUST, 28);
但在 JavaScript 中:
var d = new Date(2010, ???, 28);
我找不到包含月份常量的辅助类? Javascript 中是否存在 Java 帮助器 Calendar
类?
最佳答案
Javascript 不是 Java。
幸运的是,有像 datejs
这样的库.
Datejs is an open-source JavaScript Date Library.
Comprehensive, yet simple, stealthy and fast. Datejs has passed all trials and is ready to strike. Datejs doesn’t just parse strings, it slices them cleanly in two.
有关示例,请参阅 set()
method :
set
.set ( Object config ) : Date
Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object.
// returns Jul 15 2008 18:45:30
Date.today().set({millisecond: 500, second: 30, minute: 45, hour: 18, day: 15, month: 6, year: 2008});
关于java - Javascript 有 Java 的日历辅助类吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3591292/