javascript - 从我的浏览器中获取时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13232090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 18:09:00 来源:igfitidea点击:
javascript - Get the time out of my browser
提问by Raymond van Os
Possible Duplicate:
How to get current date in JavaScript
可能的重复:
如何在 JavaScript 中获取当前日期
How can i Get the time out of my browser whit using javascript? This do I need to make a comparison in my script.
我怎样才能使用 javascript 从我的浏览器中获取时间?这是否需要在我的脚本中进行比较。
回答by Mudassir Ali
currentTime = new Date();
time = currentTime.getTime();
hours = currentTime.getHours();
etc
等等
回答by jrajav
You can use the Date objectto get the current time:
您可以使用Date 对象来获取当前时间:
var currentTime = new Date();