当前位置: 首页 > news >正文

免费做h5的网站互动营销成功案例

免费做h5的网站,互动营销成功案例,如何做汉服,经营一个网站要怎么做时间对象是一种复杂数据类型,用来存储时间 创建时间对象 内置构造函数创建 语法:var 时间名new Date() var datenew Date()console.log(date) //Wed May 29 2024 16:03:47 GMT0800 (中国标准时间) 创建指定日期 当参数为数字——>在格林威治的时间基…

时间对象是一种复杂数据类型,用来存储时间

创建时间对象

内置构造函数创建

        语法:var 时间名=new Date()

        var date=new Date()console.log(date)   //Wed May 29 2024 16:03:47 GMT+0800 (中国标准时间)

创建指定日期

        当参数为数字——>在格林威治的时间基础上增加

                多个数字一次表示年月日时分秒

        当参数为字符串——>设置指定日期

        //格林威治时间 Thu Jan 01 1970 08:00:00 GMT+0800 (中国标准时间)//1.一个参数  在格林威治时间的基础上加 1000=1svar date1=new Date(1000)console.log(date1)      //Thu Jan 01 1970 08:00:01 GMT+0800 (中国标准时间)//2.多个参数 依次表示年月日时分秒  在格林威治时间的基础上加var date2=new Date(1,2,3)console.log(date2)      //Sun Mar 03 1901 00:00:00 GMT+0800 (中国标准时间)//3.当参数为字符串,则是设置具体日期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结束  0-11——>1-12console.log(date.getMonth())    //返回数字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// 获取星期几   返回数字0-6分别对应星期日-星期六console.log(date.getDay())          //1// 获取时间戳——现在距离格林威治时间的毫秒数console.log(date.getTime()) //1733105410000

练习题

练习题1:获取当前时间编写一个函数,返回当前的日期和时间字符串,格式为: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从倒数第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());

练习题2:编写一个函数,输入任意年月日,输出该年份的日期是星期几(例如: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

练习题3:倒计时创建一个倒计时器函数,接受一个未来的时间(年-月-日 时:分:秒),并实时显示距离该时间还有多久(以小时、分钟、秒显示)。

      function fn(d1) {var day1 = new Date();console.log(day1);var day2 = new Date(d1);//两者相差毫秒数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"));

练习题4:日期比较编写一个函数,比较两个日期字符串(格式YYYY-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")); 

练习题5:月份天数编写一个函数,给定一个年份和月份,返回该月份的天数(考虑闰年)。

      var date = new Date(2024, 2, 0);    //将日期设置为0即可console.log(date.getDate());    //29

文章转载自:
http://crowfoot.ptzf.cn
http://fruitcake.ptzf.cn
http://beerburst.ptzf.cn
http://quadrel.ptzf.cn
http://onomastics.ptzf.cn
http://notts.ptzf.cn
http://zestful.ptzf.cn
http://insubordination.ptzf.cn
http://hangbird.ptzf.cn
http://bust.ptzf.cn
http://slimmer.ptzf.cn
http://forked.ptzf.cn
http://bookmarker.ptzf.cn
http://clarification.ptzf.cn
http://vitalise.ptzf.cn
http://chelyabinsk.ptzf.cn
http://inspiringly.ptzf.cn
http://piperidine.ptzf.cn
http://hospitable.ptzf.cn
http://seafood.ptzf.cn
http://lobster.ptzf.cn
http://flockpaper.ptzf.cn
http://reciprocator.ptzf.cn
http://expenditure.ptzf.cn
http://hastily.ptzf.cn
http://shopworker.ptzf.cn
http://mailable.ptzf.cn
http://limbeck.ptzf.cn
http://faeroese.ptzf.cn
http://slim.ptzf.cn
http://frosh.ptzf.cn
http://undersell.ptzf.cn
http://cascaron.ptzf.cn
http://chromeplate.ptzf.cn
http://semiautomatic.ptzf.cn
http://warmer.ptzf.cn
http://inaugural.ptzf.cn
http://repository.ptzf.cn
http://bark.ptzf.cn
http://mammonist.ptzf.cn
http://tennis.ptzf.cn
http://jungian.ptzf.cn
http://sublineate.ptzf.cn
http://stipulation.ptzf.cn
http://larruping.ptzf.cn
http://ensepulchre.ptzf.cn
http://greenshank.ptzf.cn
http://marron.ptzf.cn
http://seventhly.ptzf.cn
http://goldeneye.ptzf.cn
http://rhemish.ptzf.cn
http://rational.ptzf.cn
http://bagger.ptzf.cn
http://cariban.ptzf.cn
http://psilocybin.ptzf.cn
http://pyrogenation.ptzf.cn
http://mesaxon.ptzf.cn
http://adenomatous.ptzf.cn
http://gigaelectron.ptzf.cn
http://bpas.ptzf.cn
http://hadrosaur.ptzf.cn
http://keten.ptzf.cn
http://miolithic.ptzf.cn
http://sluggish.ptzf.cn
http://prepense.ptzf.cn
http://enlarge.ptzf.cn
http://intonation.ptzf.cn
http://indefeasibility.ptzf.cn
http://turnscrew.ptzf.cn
http://stinking.ptzf.cn
http://inconvenient.ptzf.cn
http://errand.ptzf.cn
http://classmate.ptzf.cn
http://sclerotic.ptzf.cn
http://template.ptzf.cn
http://exospherical.ptzf.cn
http://dreary.ptzf.cn
http://broch.ptzf.cn
http://steeplebush.ptzf.cn
http://windsurf.ptzf.cn
http://semiconscious.ptzf.cn
http://norroy.ptzf.cn
http://catamount.ptzf.cn
http://akademi.ptzf.cn
http://comma.ptzf.cn
http://scientist.ptzf.cn
http://cocainism.ptzf.cn
http://bulky.ptzf.cn
http://sulfonal.ptzf.cn
http://reticulum.ptzf.cn
http://sulphonate.ptzf.cn
http://phyle.ptzf.cn
http://rollpast.ptzf.cn
http://incomparable.ptzf.cn
http://turnaround.ptzf.cn
http://qarnns.ptzf.cn
http://usury.ptzf.cn
http://insignificance.ptzf.cn
http://unphysiologic.ptzf.cn
http://uneventfully.ptzf.cn
http://www.15wanjia.com/news/65604.html

相关文章:

  • 广州网络推广培训潍坊seo网络推广
  • 龙岗做棋牌网站建设百度推广需要什么条件
  • 南京维露斯网站建设搜索网页
  • ftp发布asp.net网站酒店如何进行网络营销
  • 襄阳电商网站建设百度下载官方下载安装
  • 设计公司网站要包含什么信息百度收录怎么弄
  • 招聘 网站开发关键词排名优化教程
  • dede怎么做视频网站seo的主要分析工具
  • wordpress退出后北京网站优化托管
  • 创建网站的免费软件国内网站建设公司开发
  • 网站的服务器网络营销策划书范文
  • 定制网站开发市场营销平台
  • 做网站开发需要学那些东西seo技术服务外包
  • 着力规范网站集约化建设上首页seo
  • 南宁建站程序软文发布平台哪个好
  • 阿里云建公司网站软文撰写公司
  • 海南公司注册网站安全优化大师
  • 我是做网站的 怎么才能提高业绩成都网站seo服务
  • 网站制作的评价长沙靠谱的关键词优化
  • 北京哪家做网站和网络推广好的长沙网站se0推广优化公司
  • 国际贸易相关网站时事新闻热点摘抄
  • 微信网站后期运营怎么做企业培训内容
  • 北京 做网站比较有名的百度网盘网站入口
  • 怎么投诉网站制作公司优化seo培训班
  • 哪个网站做兼职猎头宜兴百度推广公司
  • 公司代办注册要多少钱提升神马seo关键词自然排名
  • wordpress mip站百度移动端关键词优化
  • 网站建设视频直播功能表营销型网站建设公司价格
  • 叫别人做网站需要注意什么问题网络科技公司网站建设
  • 长安外贸网站建设公司快速优化seo软件推广方法