• 2020/12/4


    得到时间

    <body>
    
    <p id="demo">点击按钮把日期和时间转换成字符串。</p>
    <button onclick="myFunction()">点我</button>
    <script>
    function myFunction(){
    	var d = new Date();
    	var x = document.getElementById("demo");
    	x.innerHTML=d.toUTCString();
    }
    </script>
    
    </body>
    
    <body>
    
    <p id="demo">周几</p>
    <button onclick="myFunction()">获取</button>
    <script>
    function myFunction(){
    	var d = new Date();
    	var weekday=new Array(7);
    	weekday[0]="周日";
    	weekday[1]="周一";
    	weekday[2]="周二";
    	weekday[3]="周三";
    	weekday[4]="周四";
    	weekday[5]="周五";
    	weekday[6]="周六";
    	var x = document.getElementById("demo");
    	x.innerHTML=weekday[d.getDay()];
    }
    
    <script>
    function startTime(){
    	var today=new Date();
    	var h=today.getHours();
    	var m=today.getMinutes();
    	var s=today.getSeconds();// 在小于10的数字前加一个‘0’
    	m=checkTime(m);
    	s=checkTime(s);
    	document.getElementById('txt').innerHTML=h+":"+m+":"+s;
    	t=setTimeout(function(){startTime()},500);
    }
    function checkTime(i){
    	if (i<10){
    		i="0" + i;
    	}
    	return i;
    }
    </script>
    </head>
    <body onload="startTime()">
    

     二.从网络上学习的时间获取,代码为转载

  • 相关阅读:
    VirtualBox 使用技巧
    ThreadPoolExecutor 线程池任务队列分析 与 利特尔法则(Little's law)
    AQS 与 LockSupport
    Matrix
    Fire Net
    Travelling
    Cannon
    N皇后问题
    Safecracker
    #include <algorithm>中sort的一般用法
  • 原文地址:https://www.cnblogs.com/qiangini/p/14161874.html
Copyright © 2020-2023  润新知