JavaScirpt

JavaScirpt

从Date类型中取形如 20091201 字符串

function  getDate(s_date) {

    
var  str_date  =   new  Array();
    str_date.push(s_date.getFullYear());
    str_date.push(s_date.getMonth() 
<   9   ?   " 0 "   +  (s_date.getMonth()  +   1 )
            : (s_date.getMonth() 
+   1 ));
    str_date.push(s_date.getDate() 
<   10   ?   " 0 "   +  s_date.getDate() : s_date
            .getDate());
    
return  str_date.join( "" );

}

你可能感兴趣的:(JavaScirpt)