<script language="Javascript">
dt = new Date();
dt_now_1 = dt.toGMTString();year = dt.getYear();
month = dt.getMonth()+1;
day = dt.getDate();dt_now_2 = year+'-'+month+'-'+day;
</script>
<input type='text' onclick="this.value=dt_now_1;">
<input type='text' onclick="this.value=dt_now_2;">

解决方案 »

  1.   

    or like this<?
    $da=date("Y-m-d");
    ?>
    <form name="FormName" action="myscript.php" method="post">
    <input name="Name" type="text" value="" onclick="this.value='<?=$da?>'">
    </form>
      

  2.   

    <script language="javascript">
    function t(o)
    {
    var a=new Date()
    o.value=a.getHours()+':'+a.getMinutes()+':'+a.getSeconds()
    }
    </script>
    <input onclick="t(this)">
      

  3.   

    <script>
    function showtime(obj)
    {
    now = new Date(); 
    year = now.getFullYear(); 
    month = now.getMonth(); 
    day = now.getDate(); 
    hour=now.getHours();
    minute=now.getMinutes();
    second=now.getSeconds();
    obj.value=year+"-"+(month+1)+"-"+day+" "+hour+":"+minute+":"+second;
    }
    </script>
    <input onclick=showtime(this)>
      

  4.   

    <script> 
    var aa;
      function getTime()
      {
        theT = new Date();
        theH = theT.getHours();
        theM = theT.getMinutes();
        theS = theT.getSeconds();
        str  = (theH<10)?('0'+theH):theH;
        str +=":";
        str += (theM<10)?('0'+ theM):theM;
        str +=":";
        str += (theS<10)?('0'+ theS):theS;
        form1.t3.value = str;
        aa = setTimeout("getTime()",500);
      }
      
      function tTime()
      {
        window.clearTimeout (aa);
      }
    </script>
      

  5.   

    <input type=text onClick="this.value=(new Date).toLocaleString()">
      

  6.   

    补充一下:
    <input type=text value=日期时间 onClick="this.value=(new Date).toLocaleString()">
    <input type=text value=仅日期 onClick="this.value=(new Date).toLocaleString().replace(/ .+/,'')">
    <input type=text value=仅时间 onClick="this.value=(new Date).toLocaleString().replace(/.+ /,'')">