<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Date</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
<div>
我们常用的时间格式是获取当前时间,从而对其进行进一步的操作,但是实际项目中往往需要 倒着 来,在W3C手册里整理如下:
var timestamp3 =newDate.setFullYear(2015,8,24)
设置之后,就可以用 正着 的get那些方法
</div>
</body>
</html>
<script>
var newDate = new Date();
var timestamp3 =newDate.setFullYear(2015,8,24); //获取到的某个毫秒数
console.log(newDate); //Tue Feb 17 2015 18:02:00 GMT+0800 (中国标准时间)
console.log(newDate.setTime(timestamp3)); //1424167320129
console.log(newDate.toDateString()); //Tue Feb 17 2015
console.log(newDate.toGMTString()); //Tue, 17 Feb 2015 10:02:00 GMT
console.log(newDate.toLocaleDateString()); //2015/2/17
console.log(newDate.toLocaleString()); //2015/2/17 下午6:02:00
console.log(newDate.toLocaleTimeString()); //下午6:02:00
console.log(newDate.toISOString()); //2015-02-17T10:02:00.129Z
</script>
About The new Date()
最新推荐文章于 2021-09-27 09:28:45 发布