您的位置:首页 > Web前端 > JavaScript

JavaScript学习笔记之Date的常用方法

2016-09-12 17:04 666 查看
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<script type="text/javascript">
// 获取系统时间:
var date = new Date();
document.write("当前时间:" + date + "<br/>");
document.write("星期:" + date.getDay() + "<br/>");
document.write("年:" + date.getFullYear() + "<br/>");
document.write("月:" + date.getMonth() + "<br/>");   // 月份从0开始;
document.write("日:" + date.getDate() + "<br/>");
document.write("时:" + date.getHours() + "<br/>");
document.write("分:" + date.getMinutes() + "<br/>");
document.write("秒:" + date.getSeconds() + "<br/>");
document.write("毫秒:" + date.getMilliseconds() + "<br/>");
document.write("微秒:" + date.getTime() + "<br/>");

// 修改时间:
date.setFullYear(2020, 11, 21);
document.write("修改后的时间:" + date + "<br/>");
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: