zoukankan      html  css  js  c++  java
  • js时间函数

    //获取今天的日期和时间
    var myDate = new Date();

    var year = myDate.getFullYear(); //年
    var month = myDate.getMonth() + 1;//月
    var date = myDate.getDate();//日
    var h = myDate.getHours(); //当前时(0-23)
    var m = myDate.getMinutes(); //当前分(0-59)
    var s = myDate.getSeconds();//当前秒(0-59)

       //获取明天的日期

       var tomorrow = new Date();

       tomorrow.setTime(tomorrow.getTime() + 24*60*60*1000);

       tomorrow_month = tomorrow.getMonth()+1;//月

     tomorrow_date =  tomorrow.getDate();//日

    //获取当前时间戳
    var now_timestamp = myDate.getTime();

    //获取指定时间的时间戳

    var time = new Date( year, myDate.getMonth(), date, h, m, s);
    var timestamp = time.getTime()

    //比较两个时间的大小(先后)
    if(now_timestamp > timestamp){
    alert('当前时间大');
    }
  • 相关阅读:
    分布式 and 集群
    时间复杂度



    线性表 & 散列表
    栈 & 队列
    数组 & 链表
    数据结构&算法
    Docket 容器引擎
  • 原文地址:https://www.cnblogs.com/jdbeyond/p/12079880.html
Copyright © 2011-2022 走看看