返回我自己写的日期......登陆

我自己写的日期案例

幸福敲门2019-03-20 23:51:03227

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Date(日期操作方法)</title>

</head>

<body>

</body>

<script>

let myDay = new Date();


document.write(myDay + "<br />");

// 获取年份

document.write(myDay.getFullYear() + "年");


// 获取月份

document.write(myDay.getMonth() + "月");


document.write("<br />");


let month = new Array(12);

month[0] = "一月"

month[1] = "二月"

month[2] = "三月"

month[3] = "四月"

month[4] = "五月"

month[5] = "六月"

month[6] = "七月"

month[7] = "八月"

month[8] = "九月"

month[9] = "十月"

month[10] = "十一月"

month[11] = "十二月"


document.write("这个月是:" + month[myDay.getMonth()]);


// 获取星期

document.write("今天是星期:" + myDay.getDay());

// 获取日期

document.write("今天是这个月的第:" + myDay.getDate() + "天");

document.write("<br />");


// 获取小时

document.write("现在是:" + myDay.getHours() + "时");


// 获取分钟

document.write(myDay.getMinutes() + "分");


// 获取秒钟

document.write(myDay.getSeconds() + "秒");

</script>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送