• input默认显示当前时间


     1 方法一:
     2 // 获取当天的年月日
     3 new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate();
     4 
     5 <form name="form1"> 
     6 
     7 <input type="text" name="test"> 
     8 </form> 
     9 <script language="JavaScript"> 
    10 today=new Date(); 
    11 form1.test.value=today.getYear()+'年'+today.getMonth()+'月'+today.getDay()+'日';
    12 </script> 
    13 
    14 <br>
    15 
    16 方法二:
    17 
    18 --------------------------------------------------------------- 
    19 
    20 <input TYPE="text" id="myDate"> 
    21 <script langguage="JavaScript"> 
    22 <!-- 
    23 var now = new Date(); 
    24 myDate.value=new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(); 
    25 //--> 
    26 </script> 
    27 
    28 <br>
    29 
    30 方法三:
    31 
    32 --------------------------------------------------------------- 
    33 
    34 <script language="JavaScript">
    35 function time_rota()  //写当前日期的函数 
    36 { 
    37     var now = new Date(); 
    38     var h = now.getFullYear(); 
    39     var m = (now.getMonth() + 1>9) ? now.getMonth() + 1 : "0"+(now.getMonth() + 1); 
    40     var s = (now.getDate()>9)  ? now.getDate()  : "0"+now.getDate(); 
    41     document.form1.Today.value = h+"年"+m+"月"+s+"日"; 
    42 } 
    43 </script> 
    44 <body onload="time_rota()"> 
    45 
    46 <form name=form1> 
    47 <input name=Today> 
    48 </form>
  • 相关阅读:
    Django REST framework 1
    爬虫基本原理
    QueryDict对象
    Django组件ModelForm
    MongoDB
    Algorithm
    BOM
    CSS
    Vue
    AliPay
  • 原文地址:https://www.cnblogs.com/colaman/p/6640750.html
Copyright © 2020-2023  润新知