var now = new Date();
var dateString = now.getMonth() + "-" + now.getDate() + "-" + now.getFullYear() + " "
+ now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
这里月份显示不正确。
例如,如果输出是 12 月,它会打印 11 月
now.getMonth() +1
将显示正确的月份。
我正在寻找更好的方法。
我的应用程序必须在两个单选按钮之间进行选择。第一个选项应返回当前系统日期和时间,其他返回从 jsp 中选择的日期和时间。在选择这两个选项中的任何一个时,它应该以特定格式将日期返回给控制器。