亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jQuery時(shí)間驗(yàn)證和轉(zhuǎn)換為標(biāo)準(zhǔn)格式的時(shí)間格式

 更新時(shí)間:2017年03月06日 09:20:01   作者:沙耶  
本篇文章主要介紹了jQuery時(shí)間驗(yàn)證和轉(zhuǎn)換為標(biāo)準(zhǔn)格式的時(shí)間示例代碼,具有一定的參考價(jià)值,有興趣的可以了解一下。

最近整理文檔發(fā)現(xiàn)一篇文章,可以將時(shí)間轉(zhuǎn)換成標(biāo)準(zhǔn)格式的時(shí)間,發(fā)出來(lái)給大家參考一下。

var TimeObjectUtil;
/**
 * @title 時(shí)間工具類
 * @note 本類一律違規(guī)驗(yàn)證返回false
 * @author {boonyachengdu@gmail.com}
 * @date 2013-07-01
 * @formatter "2013-07-01 00:00:00" , "2013-07-01"
 */
TimeObjectUtil = {
  /**
   * 獲取當(dāng)前時(shí)間毫秒數(shù)
   */
  getCurrentMsTime : function() {
    var myDate = new Date();
    return myDate.getTime();
  },
  /**
   * 毫秒轉(zhuǎn)時(shí)間格式
   */
  longMsTimeConvertToDateTime : function(time) {
    var myDate = new Date(time);
    return this.formatterDateTime(myDate);
  },
  /**
   * 時(shí)間格式轉(zhuǎn)毫秒
   */
  dateToLongMsTime : function(date) {
    var myDate = new Date(date);
    return myDate.getTime();
  },
  /**
   * 格式化日期(不含時(shí)間)
   */
  formatterDate : function(date) {
    var datetime = date.getFullYear()
        + "-"http:// "年"
        + ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
            + (date.getMonth() + 1))
        + "-"http:// "月"
        + (date.getDate() < 10 ? "0" + date.getDate() : date
            .getDate());
    return datetime;
  },
  /**
   * 格式化日期(含時(shí)間"00:00:00")
   */
  formatterDate2 : function(date) {
    var datetime = date.getFullYear()
        + "-"http:// "年"
        + ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
            + (date.getMonth() + 1))
        + "-"http:// "月"
        + (date.getDate() < 10 ? "0" + date.getDate() : date
            .getDate()) + " " + "00:00:00";
    return datetime;
  },
  /**
   * 格式化去日期(含時(shí)間)
   */
  formatterDateTime : function(date) {
    var datetime = date.getFullYear()
        + "-"http:// "年"
        + ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0"
            + (date.getMonth() + 1))
        + "-"http:// "月"
        + (date.getDate() < 10 ? "0" + date.getDate() : date
            .getDate())
        + " "
        + (date.getHours() < 10 ? "0" + date.getHours() : date
            .getHours())
        + ":"
        + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date
            .getMinutes())
        + ":"
        + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date
            .getSeconds());
    return datetime;
  },
  /**
   * 時(shí)間比較{結(jié)束時(shí)間大于開(kāi)始時(shí)間}
   */
  compareDateEndTimeGTStartTime : function(startTime, endTime) {
    return ((new Date(endTime.replace(/-/g, "/"))) > (new Date(
        startTime.replace(/-/g, "/"))));
  },
  /**
   * 驗(yàn)證開(kāi)始時(shí)間合理性{開(kāi)始時(shí)間不能小于當(dāng)前時(shí)間{X}個(gè)月}
   */
  compareRightStartTime : function(month, startTime) {
    var now = formatterDayAndTime(new Date());
    var sms = new Date(startTime.replace(/-/g, "/"));
    var ems = new Date(now.replace(/-/g, "/"));
    var tDayms = month * 30 * 24 * 60 * 60 * 1000;
    var dvalue = ems - sms;
    if (dvalue > tDayms) {
      return false;
    }
    return true;
  },
  /**
   * 驗(yàn)證開(kāi)始時(shí)間合理性{結(jié)束時(shí)間不能小于當(dāng)前時(shí)間{X}個(gè)月}
   */
  compareRightEndTime : function(month, endTime) {
    var now = formatterDayAndTime(new Date());
    var sms = new Date(now.replace(/-/g, "/"));
    var ems = new Date(endTime.replace(/-/g, "/"));
    var tDayms = month * 30 * 24 * 60 * 60 * 1000;
    var dvalue = sms - ems;
    if (dvalue > tDayms) {
      return false;
    }
    return true;
  },
  /**
   * 驗(yàn)證開(kāi)始時(shí)間合理性{結(jié)束時(shí)間與開(kāi)始時(shí)間的間隔不能大于{X}個(gè)月}
   */
  compareEndTimeGTStartTime : function(month, startTime, endTime) {
    var sms = new Date(startTime.replace(/-/g, "/"));
    var ems = new Date(endTime.replace(/-/g, "/"));
    var tDayms = month * 30 * 24 * 60 * 60 * 1000;
    var dvalue = ems - sms;
    if (dvalue > tDayms) {
      return false;
    }
    return true;
  },
  /**
   * 獲取最近幾天[開(kāi)始時(shí)間和結(jié)束時(shí)間值,時(shí)間往前推算]
   */
  getRecentDaysDateTime : function(day) {
    var daymsTime = day * 24 * 60 * 60 * 1000;
    var yesterDatsmsTime = this.getCurrentMsTime() - daymsTime;
    var startTime = this.longMsTimeConvertToDateTime(yesterDatsmsTime);
    var pastDate = this.formatterDate2(new Date(startTime));
    var nowDate = this.formatterDate2(new Date());
    var obj = {
      startTime : pastDate,
      endTime : nowDate
    };
    return obj;
  },
  /**
   * 獲取今天[開(kāi)始時(shí)間和結(jié)束時(shí)間值]
   */
  getTodayDateTime : function() {
    var daymsTime = 24 * 60 * 60 * 1000;
    var tomorrowDatsmsTime = this.getCurrentMsTime() + daymsTime;
    var currentTime = this.longMsTimeConvertToDateTime(this.getCurrentMsTime());
    var termorrowTime = this.longMsTimeConvertToDateTime(tomorrowDatsmsTime);
    var nowDate = this.formatterDate2(new Date(currentTime));
    var tomorrowDate = this.formatterDate2(new Date(termorrowTime));
    var obj = {
      startTime : nowDate,
      endTime : tomorrowDate
    };
    return obj;
  },
  /**
   * 獲取明天[開(kāi)始時(shí)間和結(jié)束時(shí)間值]
   */
  getTomorrowDateTime : function() {
    var daymsTime = 24 * 60 * 60 * 1000;
    var tomorrowDatsmsTime = this.getCurrentMsTime() + daymsTime;
    var termorrowTime = this.longMsTimeConvertToDateTime(tomorrowDatsmsTime);
    var theDayAfterTomorrowDatsmsTime = this.getCurrentMsTime()+ (2 * daymsTime);
    var theDayAfterTomorrowTime = this.longMsTimeConvertToDateTime(theDayAfterTomorrowDatsmsTime);
    var pastDate = this.formatterDate2(new Date(termorrowTime));
    var nowDate = this.formatterDate2(new Date(theDayAfterTomorrowTime));
    var obj = {
      startTime : pastDate,
      endTime : nowDate
    };
    return obj;
  }
};

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Html5的placeholder屬性(IE兼容)實(shí)現(xiàn)代碼

    Html5的placeholder屬性(IE兼容)實(shí)現(xiàn)代碼

    Placeholder是HTML5新增的另一個(gè)屬性,當(dāng)input或者textarea設(shè)置了該屬性后,該值的內(nèi)容將作為灰字提示顯示在文本框中,當(dāng)文本框獲得焦點(diǎn)時(shí),提示文字消失。以前要實(shí)現(xiàn)這效果都是用JavaScript來(lái)控制才能實(shí)現(xiàn) , firefox、google chrome等表示對(duì)其支持 , 唯獨(dú)IE不支持
    2014-08-08
  • jQuery Ajax File Upload實(shí)例源碼

    jQuery Ajax File Upload實(shí)例源碼

    這篇文章主要為大家分享了jQuery Ajax File Upload實(shí)例源碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • jquery的 filter()方法使用教程

    jquery的 filter()方法使用教程

    filter() 方法返回符合一定條件的元素。該方法讓您規(guī)定一個(gè)條件。不符合條件的元素將從選擇中移除,符合條件的元素將被返回。這篇文章主要介紹了 jquery的 filter()方法使用,需要的朋友可以參考下
    2018-03-03
  • jquery對(duì)復(fù)選框(checkbox)的操作匯總

    jquery對(duì)復(fù)選框(checkbox)的操作匯總

    本文給大家匯總介紹了一些jQuery操作復(fù)選框(checkbox)的方法和技巧,非常的簡(jiǎn)單實(shí)用,有需要的小伙伴可以參考下。
    2016-01-01
  • jQuery 移除事件的方法

    jQuery 移除事件的方法

    這篇文章主要介紹了jQuery 移除事件的方法,文中講解非常詳細(xì),代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-06-06
  • jquery如何實(shí)現(xiàn)錨點(diǎn)鏈接之間的平滑滾動(dòng)

    jquery如何實(shí)現(xiàn)錨點(diǎn)鏈接之間的平滑滾動(dòng)

    實(shí)現(xiàn)錨點(diǎn)鏈接之間的平滑滾動(dòng)的方法有很多,在接下來(lái)的文章中為大家介紹下,jquery是如何實(shí)現(xiàn)的,感興趣的朋友不要錯(cuò)過(guò)
    2013-12-12
  • jQuery實(shí)現(xiàn)圖片輪播效果代碼

    jQuery實(shí)現(xiàn)圖片輪播效果代碼

    這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)圖片輪播效果代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • jquery.Jwin.js 基于jquery的彈出層插件代碼

    jquery.Jwin.js 基于jquery的彈出層插件代碼

    測(cè)試頁(yè)面需要引用jquery的js文件 插件文件jquery.Jwin.js jquery.Jwin插件的使用參數(shù)都有詳細(xì)說(shuō)明
    2012-05-05
  • jquery實(shí)現(xiàn)點(diǎn)擊其他區(qū)域時(shí)隱藏下拉div和遮罩層的方法

    jquery實(shí)現(xiàn)點(diǎn)擊其他區(qū)域時(shí)隱藏下拉div和遮罩層的方法

    這篇文章主要介紹了jquery實(shí)現(xiàn)點(diǎn)擊其他區(qū)域時(shí)隱藏下拉div和遮罩層的方法,涉及jQuery響應(yīng)鼠標(biāo)事件動(dòng)態(tài)改變頁(yè)面元素樣式的功能,需要的朋友可以參考下
    2015-12-12
  • jQuery的緩存機(jī)制淺析

    jQuery的緩存機(jī)制淺析

    這篇文章主要介紹了jQuery的緩存機(jī)制淺析,并且模擬jQuery自己寫(xiě)了一個(gè)簡(jiǎn)單的緩存系統(tǒng)實(shí)例,需要的朋友可以參考下
    2014-06-06

最新評(píng)論