帝国cms发布时间字段的“设为当前时间”修改为实时时间

2022-09-16 17:29:02秋军

 

找到系统--数据表与系统模型--管理数据表,选择要修改的表的字段,

 

 

进入管理字段之后选择修改系统字段newstime

将输入表单替换html代码

替换为:


<input name="newstime" type="text" value="<?=$r[newstime]?>" size="28" class="Wdate" onClick="WdatePicker({skin:'default',dateFmt:'yyyy-MM-dd HH:mm:ss'})"><input type=button name=button value="设为当前时间" onclick="CurentTime()">

<script>
function CurentTime()  
    {   
        var now = new Date();  
          
        var year = now.getFullYear();       //年  
        var month = now.getMonth() + 1;     //月  
        var day = now.getDate();            //日  
          
        var hh = now.getHours();            //时  
        var mm = now.getMinutes();          //分  
        var ss = now.getSeconds();           //秒  
          
        var clock = year + "-";  
          
        if(month < 10)  
            clock += "0";  
          
        clock += month + "-";  
          
        if(day < 10)  
            clock += "0";  
              
        clock += day + " ";  
          
        if(hh < 10)  
            clock += "0";  
              
        clock += hh + ":";  
        if (mm < 10) clock += '0';   
        clock += mm + ":";   
           
        if (ss < 10) clock += '0';   
        clock += ss;   
/*return(clock);
$todaytime*/
document.add.newstime.value=clock;

}
</script>
 

 

OK,完成了!