中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

免費做h5的網(wǎng)站展示型網(wǎng)站有哪些

免費做h5的網(wǎng)站,展示型網(wǎng)站有哪些,wordpress start,wordpress模板視頻時間對象是一種復(fù)雜數(shù)據(jù)類型,用來存儲時間 創(chuàng)建時間對象 內(nèi)置構(gòu)造函數(shù)創(chuàng)建 語法:var 時間名new Date() var datenew Date()console.log(date) //Wed May 29 2024 16:03:47 GMT0800 (中國標準時間) 創(chuàng)建指定日期 當參數(shù)為數(shù)字——>在格林威治的時間基…

時間對象是一種復(fù)雜數(shù)據(jù)類型,用來存儲時間

創(chuàng)建時間對象

內(nèi)置構(gòu)造函數(shù)創(chuàng)建

????????語法:var 時間名=new Date()

        var date=new Date()console.log(date)   //Wed May 29 2024 16:03:47 GMT+0800 (中國標準時間)

創(chuàng)建指定日期

? ? ? ? 當參數(shù)為數(shù)字——>在格林威治的時間基礎(chǔ)上增加

? ? ? ? ? ? ? ? 多個數(shù)字一次表示年月日時分秒

? ? ? ? 當參數(shù)為字符串——>設(shè)置指定日期

        //格林威治時間 Thu Jan 01 1970 08:00:00 GMT+0800 (中國標準時間)//1.一個參數(shù)  在格林威治時間的基礎(chǔ)上加 1000=1svar date1=new Date(1000)console.log(date1)      //Thu Jan 01 1970 08:00:01 GMT+0800 (中國標準時間)//2.多個參數(shù) 依次表示年月日時分秒  在格林威治時間的基礎(chǔ)上加var date2=new Date(1,2,3)console.log(date2)      //Sun Mar 03 1901 00:00:00 GMT+0800 (中國標準時間)//3.當參數(shù)為字符串,則是設(shè)置具體日期var date3=new Date('2001-12-12 10:10:10')console.log(date3)  //Wed Dec 12 2001 10:10:10 GMT+0800 (中國標準時間)var date4=new Date('2001/12/12 10:10:10')console.log(date4)  //Wed Dec 12 2001 10:10:10 GMT+0800 (中國標準時間)var date5=new Date('2001/12/12 10:10:10','2002/12/12 10:10:10')console.log(date5)  //Invalid Date  無效日期

事件對象方法

        var date=new Date('2024/12/2 10:10:10')//獲取年份console.log(date.getFullYear()) //2024//獲取月份 月是從0開始到11結(jié)束  0-11——>1-12console.log(date.getMonth())    //返回數(shù)字11  // 獲取日期console.log(date.getDate())     //2// 獲取時間console.log(date.getHours())    //10// 獲取分鐘console.log(date.getMinutes())  //10// 獲取秒console.log(date.getSeconds())  //10// 獲取毫秒console.log(date.getMilliseconds()) //0// 獲取星期幾   返回數(shù)字0-6分別對應(yīng)星期日-星期六console.log(date.getDay())          //1// 獲取時間戳——現(xiàn)在距離格林威治時間的毫秒數(shù)console.log(date.getTime()) //1733105410000

練習(xí)題

練習(xí)題1:獲取當前時間編寫一個函數(shù),返回當前的日期和時間字符串,格式為:YYYY-MM-DD-MM-DD HH:mm:ss。

function getCurrentDateTime() {var now = new Date();var year = now.getFullYear();var month = ("0" + (now.getMonth() + 1)).slice(-2);//slice從倒數(shù)第2位開始截取var day = ("0" + now.getDate()).slice(-2);var hours = ("0" + now.getHours()).slice(-2);var minutes = ("0" + now.getMinutes()).slice(-2);var seconds = ("0" + now.getSeconds()).slice(-2);return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
}console.log(getCurrentDateTime());

練習(xí)題2:編寫一個函數(shù),輸入任意年月日,輸出該年份的日期是星期幾(例如:0代表周日,1代表周一,以此類推)。

      function fn(argDay) {var day = new Date(argDay);return day.getDay();}console.log(fn("2020/12/2"));        //3console.log(fn("2023/01/12"));       //4console.log(fn("2024/5/27"));        //1

練習(xí)題3:倒計時創(chuàng)建一個倒計時器函數(shù),接受一個未來的時間(年-月-日 時:分:秒),并實時顯示距離該時間還有多久(以小時、分鐘、秒顯示)。

      function fn(d1) {var day1 = new Date();console.log(day1);var day2 = new Date(d1);//兩者相差毫秒數(shù)var timer = Math.abs(day1.getTime() - day2.getTime()) / 1000;console.log(timer);//1小時=60分鐘=3600秒  =3600 000毫秒var h = parseInt(timer / 3600);var m = parseInt((timer - h * 3600) / 60);var s = parseInt(timer - h * 3600 - m * 60);return h + ":" + m + ":" + s;}console.log(fn("2024/5/31 20:25:20"));

練習(xí)題4:日期比較編寫一個函數(shù),比較兩個日期字符串(格式Y(jié)YYY-MM-DD),返回哪一個日期更早。

function compareDates(dateStr1, dateStr2) {var date1 = new Date(dateStr1);var date2 = new Date(dateStr2);return date1.getTime() < date2.getTime() ? dateStr1 : dateStr2;
}console.log(compareDates("2023-01-01", "2023-12-31")); 

練習(xí)題5:月份天數(shù)編寫一個函數(shù),給定一個年份和月份,返回該月份的天數(shù)(考慮閏年)。

      var date = new Date(2024, 2, 0);    //將日期設(shè)置為0即可console.log(date.getDate());    //29
http://www.risenshineclean.com/news/34173.html

相關(guān)文章:

  • 做室內(nèi)設(shè)計的網(wǎng)站有哪些內(nèi)容數(shù)字營銷服務(wù)商seo
  • 日本設(shè)計創(chuàng)意網(wǎng)站web網(wǎng)站設(shè)計
  • 萊蕪網(wǎng)站優(yōu)化招聘網(wǎng)seo搜索如何優(yōu)化
  • 學(xué)用mvc做網(wǎng)站重慶seo網(wǎng)絡(luò)推廣優(yōu)化
  • vue做移動端網(wǎng)站與pc端有什么區(qū)別網(wǎng)站推廣軟件免費版下載
  • 網(wǎng)站開發(fā)的項目開發(fā)網(wǎng)站開發(fā)公司排行榜
  • 品牌廣告設(shè)計制作公司網(wǎng)站源碼班級優(yōu)化大師的功能有哪些
  • wordpress使用兩個主題如何推廣seo
  • 獨立站都有哪些百度快速排名提升
  • 網(wǎng)站投票活動怎么做百度域名注冊查詢
  • 沒有網(wǎng)站怎么做seob站推廣平臺
  • 網(wǎng)站報名怎么做市場營銷培訓(xùn)
  • 網(wǎng)站目錄鏈接怎么做天津百度推廣電話
  • 粉色做網(wǎng)站背景圖片競價推廣是什么意思
  • 臨汾哪做網(wǎng)站seo關(guān)鍵詞優(yōu)化推廣哪家好
  • 京東淘寶網(wǎng)站是怎么做的360免費做網(wǎng)站
  • 微信鏈接網(wǎng)頁網(wǎng)站制作網(wǎng)站seo優(yōu)化推廣
  • wordpress quizzin網(wǎng)站怎樣優(yōu)化關(guān)鍵詞好
  • 大興智能網(wǎng)站建設(shè)哪家好企業(yè)營銷策劃
  • 吉林省住房城鄉(xiāng)建設(shè)廳網(wǎng)站首頁什么是搜索推廣
  • 設(shè)計網(wǎng)站價格鄭州seo軟件
  • 湖南網(wǎng)絡(luò)公司網(wǎng)站建設(shè)seo教學(xué)平臺
  • 網(wǎng)站如何運營賺錢線下推廣方式都有哪些
  • 慈溪做網(wǎng)站網(wǎng)站打開速度優(yōu)化
  • 公安網(wǎng)站建設(shè)公司網(wǎng)站與推廣
  • 莆田做網(wǎng)站的公司住房和城鄉(xiāng)建設(shè)部官網(wǎng)
  • 個體做外貿(mào)的網(wǎng)站2021百度模擬點擊工具
  • 企業(yè)微信網(wǎng)站建設(shè)東莞做網(wǎng)站哪里好
  • 南通公司網(wǎng)站建設(shè)怎么做網(wǎng)站推廣和宣傳
  • 空調(diào)維修技術(shù)支持東莞網(wǎng)站建設(shè)國家最新新聞