zoukankan      html  css  js  c++  java
  • js时间转换+比较 Date.parse的兼容

    var tip = setInterval("checkTime()", "10000");
        var temp = document.getElementById("hidden_endT").value;
        var datereturn = toDate(temp);
        function checkTime() {
            var myTime=Date();
            if (Date.parse(myTime) > datereturn) {
                clearInterval(tip);
                var auctionCode=document.getElementById("auctionCode").value;
                window.open("ResultAuction.aspx?auctionCode=" + auctionCode, "_self");
            }
        }
        function toDate(getTemp) {

            temp = getTemp.split(" ");
            var dateReturn = temp[0].split("-")[1] + "-" + temp[0].split("-")[2] + "-" + temp[0].split("-")[0] + " " + temp[1].split(":")[0] + ":" + temp[1].split(":")[1] + ":" + temp[1].split(":")[2];
            return Date.parse(dateReturn);
        }

    比较的时间格式:2012-8-30 17:45:00

    不兼容火狐浏览器         var dateReturn = temp[0].split("-")[1] + "/" + temp[0].split("-")[2] + "/" + temp[0].split("-")[0] + " " + temp[1].split(":")[0] + ":" + temp[1].split(":")[1] + ":" + temp[1].split(":")[2]; 将-改成/,就ok了。

  • 相关阅读:
    SVG.js 文本绘制整理
    SVG.js 基础图形绘制整理(二)
    SVG.js 基础图形绘制整理(一)
    C# 异步编程Task整理(一)
    Svg.Js 父类的基础操作
    Svg.Js A标签,链接操作
    Svg.Js 简介(转)
    SVG 相关整理
    Kendo UI
    Kendo UI
  • 原文地址:https://www.cnblogs.com/wuchao/p/2663822.html
Copyright © 2011-2022 走看看