慕粉0202
2018-03-24 19:02:19浏览 1987
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" media="(device-height: 568px)">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name='apple-touch-fullscreen' content='yes'>
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="address=no">
<title>购物车</title>
<link href="css/base.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<script>
//获取当前时间戳的三种方法
var time1=Date.parse(new Date()); //1521884544000 毫秒不精确,毫秒是000显示
var time2=(new Date()).valueOf(); //1521884544653 第二种和第三种获取当前毫秒的时间戳
var time3=new Date().getTime(); //1521884544653
var time=new Date();
formatDate(time);
function formatDate(time){
var year=time.getFullYear();
var month=checkTime(time.getMonth()+1);
var day=checkTime(time.getDate());
var hours=checkTime(time.getHours());
var min=checkTime(time.getMinutes());
var sec=checkTime(time.getSeconds());
var date=year+'-'+month+'-'+day+'-'+hours+':'+min+':'+sec
document.write(date);
//小于10的时间前面+0
function checkTime(time){
if(time<10){
time= '0'+time
}
return time;
}
}
</script>
</body>
</html>