JavaScript 日历操作
我有这样的 Java 代码:
//first moment of the today
Calendar cal = new GregorianCalendar();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Calendar tomorrow = (Calendar)cal.clone();
tomorrow.add(Calendar.DAY_OF_YEAR, 1);
long time = d.getTime();
// if greater than today's first moment
if(time >= tomorrow.getTimeInMillis()){
...
}
...
如何用 JavaScript 重写它?
I have Java code like that:
//first moment of the today
Calendar cal = new GregorianCalendar();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Calendar tomorrow = (Calendar)cal.clone();
tomorrow.add(Calendar.DAY_OF_YEAR, 1);
long time = d.getTime();
// if greater than today's first moment
if(time >= tomorrow.getTimeInMillis()){
...
}
...
How can I rewrite it with JavaScript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设 d 是您从其他地方获得的日期对象:
http://www. w3schools.com/jsref/jsref_obj_date.asp
i'm going to assume d is a date object you got from somewhere else:
http://www.w3schools.com/jsref/jsref_obj_date.asp