1. 程式人生 > 實用技巧 >時間日期格式yyyy-mm-dd hh:mm:ss 和天氣外掛

時間日期格式yyyy-mm-dd hh:mm:ss 和天氣外掛

        1. 獲取時間

          getTime(){ setInterval(()=>{ letmyDate=newDate(); letyear=myDate.getFullYear(); letmonth=myDate.getMonth()+1; letdate=myDate.getDate(); lethours=myDate.getHours(); letminutes=myDate.getMinutes(); letseconds=myDate.getSeconds(); varweek="星期"+"日一二三四五六".charAt(myDate.getDay()); hours=this.check(hours); minutes=this.check(minutes); seconds=this.check(seconds); this.times= year+ "-"+ month+ "-"+ date+ "\xa0"+ hours+ ":"+ minutes+ ":"+ seconds+ "\xa0\xa0\xa0"+ week; },1000); },   //不夠兩位補充 0 check(i){ letnum; i<10?(num="0"+i):(num=i); returnnum; },      

           

        2. 天氣外掛

          <iframe width="200" scrolling="no" height="55" frameborder="0" allowtransparency="true" src="https://i.tianqi.com?c=code&id=35&icon=1&num=5&site=12"></iframe>
          

          https://www.tianqi.com/yangshishezhi.html?id=35&h=55&w=200根據專案去求修改天氣樣式