jquery里,怎么格式化时间

jquery里,怎么格式化时间,第1张

createTime是一个Json格式的日期,

var JsonDateValue = new Date(createTimetime);

var text = JsonDateValuegetYear()+"-"+JsonDateValuegetMonth()+"-"+JsonDateValuegetDay()+" "+JsonDateValuegetHours()+":"+JsonDateValuegetMinutes()+":"+JsonDateValuegetSeconds();

//text=“2012-12-22 21:20:12”

或者

  时间对象的格式化; 

 /  

Dateprototypeformat = function(format) {  

    / 

      使用例子:format="yyyy-MM-dd hh:mm:ss"; 

     /  

    var o = {  

        "M+" : thisgetMonth() + 1, // month  

        "d+" : thisgetDate(), // day  

        "h+" : thisgetHours(), // hour  

        "m+" : thisgetMinutes(), // minute  

        "s+" : thisgetSeconds(), // second  

        "q+" : Mathfloor((thisgetMonth() + 3) / 3), // quarter  

        "S" : thisgetMilliseconds()  

        // millisecond  

    }  

  

    if (/(y+)/test(format)) {  

        format = formatreplace(RegExp$1, (thisgetFullYear() + "")substr(4  

                        - RegExp$1length));  

    }  

  

    for (var k in o) {  

        if (new RegExp("(" + k + ")")test(format)) {  

            format = formatreplace(RegExp$1, RegExp$1length == 1  

                             o[k]  

                            : ("00" + o[k])substr(("" + o[k])length));  

        }  

    }  

    return format;  

}

是本地页面时间,前端一般获取的都是本地时间。

JQuery CountDown里面都是通过new Date的方式和setInterval定时方式进行的。

一般countdown的初始时间最好是从服务器给定,然后倒计时。

以上就是关于jquery里,怎么格式化时间全部的内容,包括:jquery里,怎么格式化时间、jQuery Countdown 获取的是服务器时间还是本地时间、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9591641.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存