您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

js日期时间补零的小例子_javascript技巧

2024/3/16 19:29:57发布17次查看
复制代码 代码如下:
function getnowformatdate()
        {
           var day = new date();
           var year = 0;
           var month = 0;
           var day = 0;
           var currentdate = ;
           //初始化时间
           //year       = day.getyear();//有火狐下2008年显示108的bug
           year       = day.getfullyear();//ie火狐下都可以
           month      = day.getmonth()+1;
           day        = day.getdate();
           currentdate += year + -;
           if (month >= 10 )
           {
            currentdate += month + -;
           }
           else
           {
            currentdate += 0 + month + -;
           }
           if (day >= 10 )
           {
            currentdate += day ;
           }
           else
           {
            currentdate += 0 + day ;
           }
return currentdate;
        }
//获取的时间就会补零
var nowdate = getnowformatdate();
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product