45IT.COM- µçÄÔѧϰ´Ó´Ë¿ªÊ¼£¡
DIYÓ²¼þ½Ì³ÌÔÜ»ú¾­Ñé×°»úÅäÖÃ
Éè¼ÆPhotoshopÍøÒ³Éè¼ÆÌØЧ
ϵͳע²á±íDOSϵͳÃüÁîÆäËü
´æ´¢Ö÷°åÏÔ¿¨ÍâÉè¼üÊóÄÚ´æ
άÐÞÏÔ¿¨CPUÄÚ´æ´òÓ¡»ú
WinXPVistaWin7unix/linux
CPU¹âÇýµçÔ´/É¢ÈÈÏÔʾÆ÷ÆäËü
ÐÞ¼¼Ö÷°åÓ²Å̼üÊóÏÔʾÆ÷¹âÇý
°ì¹«ExcelWordPowerPointWPS
±à³ÌÊý¾Ý¿âCSS½Å±¾PHP
ÍøÂç¾ÖÓòÍøQQ·þÎñÆ÷
Èí¼þÍøÂçϵͳͼÏñ°²È«

JavascriptÈÕÆÚ¸ñʽ»¯º¯ÊýÐÔÄܶԱÈ

µçÄÔÈíÓ²¼þÓ¦ÓÃÍø 45IT.COM ʱ¼ä:2013-07-16 13:52 ×÷Õß:ØýÃû

×î½ü¿ª·¢µÄÈí¼þÖÐÐèÒªÓõ½ÈÕÖ¾¹¦ÄÜ£¬ÆäÖÐÓÐÒ»¸öÖØÒª¹¦ÄÜÊÇÏÔʾÈÕÆÚºÍʱ¼ä¡£ÓÚÊÇÍøÉÏËÑÁËÒ»°Ñ£¬Ëѵ½´óÁ¿µÄÈÕÆÚ¸ñʽ»¯º¯Êý£¬²»¹ý±È½ÏÁËÏ£¬¸Ð¾õ´úÂ붼²»¹»ÓÅÑÅ£¬¶øÇÒÐÔÄܶ¼²»¸øÁ¦¡£

¶ÔÏßÉÏһЩ´úÂë½øÐÐÁËÆÀ²â£¬½á¹ûÈçÏ£º

²âÊÔ´úÂëÈçÏ£¬·Ö±ð¶Ô¸ñʽ»¯º¯Êý½øÐÐ50Íò´Î¼ÆË㣺

 ´úÂëÈçÏ  

var start = new Date().getTime();

var date = new Date();

for(var i = 0;i<500000;i++){

    date.format1('yyyy-MM-dd hh:mm:ss');

}

console.log(new Date().getTime() - start);


º¯Êý1£º

 ´úÂëÈçÏ  

// ¶ÔDateµÄÀ©Õ¹£¬½« Date ת»¯ÎªÖ¸¶¨¸ñʽµÄString

// ÔÂ(M)¡¢ÈÕ(d)¡¢Ð¡Ê±(h)¡¢·Ö(m)¡¢Ãë(s)¡¢¼¾¶È(q) ¿ÉÒÔÓà 1-2 ¸öռλ·û£¬

// Äê(y)¿ÉÒÔÓà 1-4 ¸öռλ·û£¬ºÁÃë(S)Ö»ÄÜÓà 1 ¸öռλ·û(ÊÇ 1-3 λµÄÊý×Ö)

// Àý×Ó£º

// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423

// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18

Date.prototype.format1 = function (fmt) { //author: meizz

    var o = {

        "M+": this.getMonth() + 1, //Ô·Ý

        "d+": this.getDate(), //ÈÕ

        "h+": this.getHours(), //Сʱ

        "m+": this.getMinutes(), //·Ö

        "s+": this.getSeconds(), //Ãë

        "q+": Math.floor((this.getMonth() + 3) / 3), //¼¾¶È

        "S": this.getMilliseconds() //ºÁÃë

    };

    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));

    for (var k in o)

    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));

    return fmt;

}

 

²âÊÔÈý´Î£º

³É¼¨1£º6657ºÁÃë

³É¼¨2£º6739ºÁÃë

³É¼¨3£º6747ºÁÃë

ƽ¾ù£º6714ºÁÃë

 

º¯Êý2£º

 ´úÂëÈçÏ  

/** * ¶ÔDateµÄÀ©Õ¹£¬½« Date ת»¯ÎªÖ¸¶¨¸ñʽµÄString * ÔÂ(M)¡¢ÈÕ(d)¡¢12Сʱ(h)¡¢24Сʱ(H)¡¢·Ö(m)¡¢Ãë(s)¡¢ÖÜ(E)¡¢¼¾¶È(q)

    ¿ÉÒÔÓà 1-2 ¸öռλ·û * Äê(y)¿ÉÒÔÓà 1-4 ¸öռλ·û£¬ºÁÃë(S)Ö»ÄÜÓà 1 ¸öռλ·û(ÊÇ 1-3 λµÄÊý×Ö) * eg: * (new

    Date()).pattern("yyyy-MM-dd hh:mm:ss.S")==> 2006-07-02 08:09:04.423     

 * (new Date()).pattern("yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 ¶þ 20:09:04     

 * (new Date()).pattern("yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 Öܶþ 08:09:04     

 * (new Date()).pattern("yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 ÐÇÆÚ¶þ 08:09:04     

 * (new Date()).pattern("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18     

 */ 

Date.prototype.format2=function(fmt) {        

    var o = {        

    "M+" : this.getMonth()+1, //Ô·ݠ       

    "d+" : this.getDate(), //ÈÕ        

    "h+" : this.getHours()%12 == 0 ? 12 : this.getHours()%12, //Сʱ        

    "H+" : this.getHours(), //Сʱ        

    "m+" : this.getMinutes(), //·Ö        

    "s+" : this.getSeconds(), //Ãë        

    "q+" : Math.floor((this.getMonth()+3)/3), //¼¾¶È        

    "S" : this.getMilliseconds() //ºÁÃë        

    };        

    var week = {        

    "0" : "/u65e5",        

    "1" : "/u4e00",        

    "2" : "/u4e8c",        

    "3" : "/u4e09",        

    "4" : "/u56db",        

    "5" : "/u4e94",        

    "6" : "/u516d"       

    };        

    if(/(y+)/.test(fmt)){        

        fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));        

    }        

    if(/(E+)/.test(fmt)){        

        fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "/u661f/u671f" : "/u5468") : "")+week[this.getDay()+""]);        

    }        

    for(var k in o){        

        if(new RegExp("("+ k +")").test(fmt)){        

            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));        

        }        

    }        

    return fmt;        

}

 

 


²âÊÔÈý´Î£º

³É¼¨1£º7334ºÁÃë

³É¼¨2£º7497ºÁÃë

³É¼¨3£º7498ºÁÃë

ƽ¾ù£º7443ºÁÃë

 

±¾×ÅÍêÃÀÖ÷ÒåµÄ̬¶È£¬×Ô¼ºÖØÐÂÔìÁ˸ö¸üºÃµÄÂÖ×Ó£¬·ÖÏí¸øÐèÒªµÄͬѧÃÇ£¬´úÂëÈçÏ£º

 ´úÂëÈçÏ  

/**

 * ¶ÔÈÕÆÚ½øÐиñʽ»¯£¬

 * @param date Òª¸ñʽ»¯µÄÈÕÆÚ

 * @param format ½øÐиñʽ»¯µÄģʽ×Ö·û´®

 *     Ö§³ÖµÄģʽ×ÖĸÓУº

 *     y:Äê,

 *     M:ÄêÖеÄÔ·Ý(1-12),

 *     d:Ô·ÝÖеÄÌì(1-31),

 *     h:Сʱ(0-23),

 *     m:·Ö(0-59),

 *     s:Ãë(0-59),

 *     S:ºÁÃë(0-999),

 *     q:¼¾¶È(1-4)

 * @return String

 * @author yanis.wang@gmail.com

 */

function dateFormat(date, format) {

    if(format === undefined){

        format = date;

        date = new Date();

    }

    var map = {

        "M": date.getMonth() + 1, //Ô·Ý

        "d": date.getDate(), //ÈÕ

        "h": date.getHours(), //Сʱ

        "m": date.getMinutes(), //·Ö

        "s": date.getSeconds(), //Ãë

        "q": Math.floor((date.getMonth() + 3) / 3), //¼¾¶È

        "S": date.getMilliseconds() //ºÁÃë

    };

    format = format.replace(/([yMdhmsqS])+/g, function(all, t){

        var v = map[t];

        if(v !== undefined){

            if(all.length > 1){

                v = '0' + v;

                v = v.substr(v.length-2);

            }

            return v;

        }

        else if(t === 'y'){

            return (date.getFullYear() + '').substr(4 - all.length);

        }

        return all;

    });

    return format;

}

 

ʹÓ÷½·¨£º

dateFormat('yyyy-MM-dd hh:mm:ss');

dateFormat(new Date(), 'yyyy-MM-dd hh:mm:ss');

 

²âÊÔÈý´Î£º

³É¼¨1£º2903ºÁÃë

³É¼¨2£º2900ºÁÃë

³É¼¨3£º2896ºÁÃë

ƽ¾ù£º2899ºÁÃë

¾­¹ý¸ÄÔìµÄº¯Êý£¬ÕûÌåÉÏÐÔÄÜÌáÉýÃ÷ÏÔ£¬´Ó6714ºÁÃëÌáÉýµ½2899ºÁÃ룬¼õÉÙÁË3815ºÁÃ룬ÕûÌå½µµ½Ô­43%µÄʱ¼ä£¬ÐÔÄÜÌáÉýÒ»±¶ÒÔÉÏ¡£²¢ÇÒ´ÓÔ­ÐÎ×¢È뷽ʽ¸ÄΪ¾²Ì¬º¯Êý·½Ê½£¬¸üÓÅÑŴ󷽡£

¶¥Ò»ÏÂ
(0)
0%
²ÈÒ»ÏÂ
(0)
0%
------·Ö¸ôÏß----------------------------
ÎÞ·¨ÔÚÕâ¸öλÖÃÕÒµ½£º baidushare.htm
·¢±íÆÀÂÛ
Çë×Ô¾õ×ñÊØ»¥ÁªÍøÏà¹ØµÄÕþ²ß·¨¹æ£¬ÑϽû·¢²¼É«Çé¡¢±©Á¦¡¢·´¶¯µÄÑÔÂÛ¡£
ÆÀ¼Û:
񡀂:
ÑéÖ¤Âë:µã»÷ÎÒ¸ü»»Í¼Æ¬
ÍƼö֪ʶ