码迷,mamicode.com
首页 > 其他好文 > 详细

获取一天开始和结束时间的毫秒值

时间:2016-05-24 15:01:49      阅读:979      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html >
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>一天开始和结束毫秒值</title>
</head>

<body>
<button id="showBtn">click</button>

<script>
window.onload=function(){
document.getElementsByTagName(‘button‘)[0].onclick=function(){
//var _d=new Date();
//_d.setHours(0);
//_d.setMinutes(0);
//_d.setSeconds(0);
//_d.setMilliseconds(0);//设置小时分钟秒毫秒时间为零点
var now=new Date().getTime();//获取当前时间毫秒值
console.log((now-now%86400000)+‘_‘+(_d.getTime())+‘_‘+(now+86400000-now%86400000))

}}//console出来的结果,前一部分是一天开始的毫秒值,最后是一天结束的毫秒值,中间部分,和两边都不一样
</script>
</body>
</html>

获取一天开始和结束时间的毫秒值

标签:

原文地址:http://www.cnblogs.com/ziluohuanghun/p/5523239.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!