如何利用javascript 获得当前时间 ,格式如:  2008-06-15 15:41:11

解决方案 »

  1.   

    var now = new Date();
    now.getYear()+'-'+(now.getMonth()+1)+'-'+now.getDate()+' '+now.getHours()+':'+now.getMinutes()+":"+now.getSeconds()
      

  2.   


    var now = new Date();
    var time = now.getFullYear() + "-" + 
               (now.getMonth() + 1) + "-" + 
               now.getDate() + " " + 
               now.getHours() + ":" + 
               now.getMinutes() + ":" + 
               now.getSeconds();
      

  3.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <SCRIPT LANGUAGE="JavaScript">
      <!--
    var now = new Date();
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    (month < 10) ? (month = '0'+month) : month;
    var date = now.getDate();
    var Temp = year + '-' + month + '-' + date + ' ' + Date().split(" ")[3] ;
    alert(Temp);
      //-->
      </SCRIPT>
     </HEAD> <BODY>
      
     </BODY>
    </HTML>
      

  4.   

    Date对象加上合适的转换格式。