当前位置:首页 > 开发 > Web前端 > JavaScript > 正文

javascript初始化时间

发表于: 2011-06-16   作者:ctrain   来源:转载   浏览:
摘要: <script type="text/javascript">  function init(){   var tempDate = new Date(); var currDate = ChangeDateToString(tempDate);   var startDate = document.getEle
<script type="text/javascript">
 function init(){
    var tempDate = new Date();
    var currDate = ChangeDateToString(tempDate);
    var startDate = document.getElementById("queryStartDate");
    var endDate =document.getElementById("queryEndDate");
    startDate.value = currDate;
    endDate.value = currDate;
 }
 function ChangeDateToString(DateIn){   
    var Year = 0;   
    var Month = 0;   
    var Day = 0;        
    var CurrentDate = "";   
               
    //初始化时间   
     Year  = DateIn.getYear();   
     Month  = DateIn.getMonth()+1;   
     Day  = DateIn.getDate();        
     CurrentDate = Year + "-";   
     if (Month >= 10 ){   
         CurrentDate = CurrentDate + Month + "-";   
     } else{   
         CurrentDate = CurrentDate + "0" + Month + "-";   
     }   
     if (Day >= 10 ){   
         CurrentDate = CurrentDate + Day ;   
     } else{   
         CurrentDate = CurrentDate + "0" + Day ;   
     }   
   
     return CurrentDate;   
 }  
 </script>

 

javascript初始化时间

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号